You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

286 lines
7.3 KiB

  1. # Command Reference
  2. Like `git`, the `pyenv` command delegates to subcommands based on its
  3. first argument.
  4. The most common subcommands are:
  5. * [`pyenv commands`](#pyenv-commands)
  6. * [`pyenv local`](#pyenv-local)
  7. * [`pyenv global`](#pyenv-global)
  8. * [`pyenv shell`](#pyenv-shell)
  9. * [`pyenv install`](#pyenv-install)
  10. * [`pyenv uninstall`](#pyenv-uninstall)
  11. * [`pyenv rehash`](#pyenv-rehash)
  12. * [`pyenv version`](#pyenv-version)
  13. * [`pyenv versions`](#pyenv-versions)
  14. * [`pyenv which`](#pyenv-which)
  15. * [`pyenv whence`](#pyenv-whence)
  16. ## `pyenv commands`
  17. Lists all available pyenv commands.
  18. ## `pyenv local`
  19. Sets a local application-specific Python version by writing the version
  20. name to a `.python-version` file in the current directory. This version
  21. overrides the global version, and can be overridden itself by setting
  22. the `PYENV_VERSION` environment variable or with the `pyenv shell`
  23. command.
  24. $ pyenv local 2.7.6
  25. When run without a version number, `pyenv local` reports the currently
  26. configured local version. You can also unset the local version:
  27. $ pyenv local --unset
  28. Previous versions of pyenv stored local version specifications in a
  29. file named `.pyenv-version`. For backwards compatibility, pyenv will
  30. read a local version specified in an `.pyenv-version` file, but a
  31. `.python-version` file in the same directory will take precedence.
  32. ### `pyenv local` (advanced)
  33. You can specify multiple versions as local Python at once.
  34. Let's say if you have two versions of 2.7.6 and 3.3.3. If you prefer 2.7.6 over 3.3.3,
  35. $ pyenv local 2.7.6 3.3.3
  36. $ pyenv versions
  37. system
  38. * 2.7.6 (set by /Users/yyuu/path/to/project/.python-version)
  39. * 3.3.3 (set by /Users/yyuu/path/to/project/.python-version)
  40. $ python --version
  41. Python 2.7.6
  42. $ python2.7 --version
  43. Python 2.7.6
  44. $ python3.3 --version
  45. Python 3.3.3
  46. or, if you prefer 3.3.3 over 2.7.6,
  47. $ pyenv local 3.3.3 2.7.6
  48. $ pyenv versions
  49. system
  50. * 2.7.6 (set by /Users/yyuu/path/to/project/.python-version)
  51. * 3.3.3 (set by /Users/yyuu/path/to/project/.python-version)
  52. venv27
  53. $ python --version
  54. Python 3.3.3
  55. $ python2.7 --version
  56. Python 2.7.6
  57. $ python3.3 --version
  58. Python 3.3.3
  59. ## `pyenv global`
  60. Sets the global version of Python to be used in all shells by writing
  61. the version name to the `~/.pyenv/version` file. This version can be
  62. overridden by an application-specific `.python-version` file, or by
  63. setting the `PYENV_VERSION` environment variable.
  64. $ pyenv global 2.7.6
  65. The special version name `system` tells pyenv to use the system Python
  66. (detected by searching your `$PATH`).
  67. When run without a version number, `pyenv global` reports the
  68. currently configured global version.
  69. ### `pyenv global` (advanced)
  70. You can specify multiple versions as global Python at once.
  71. Let's say if you have two versions of 2.7.6 and 3.3.3. If you prefer 2.7.6 over 3.3.3,
  72. $ pyenv global 2.7.6 3.3.3
  73. $ pyenv versions
  74. system
  75. * 2.7.6 (set by /Users/yyuu/.pyenv/version)
  76. * 3.3.3 (set by /Users/yyuu/.pyenv/version)
  77. $ python --version
  78. Python 2.7.6
  79. $ python2.7 --version
  80. Python 2.7.6
  81. $ python3.3 --version
  82. Python 3.3.3
  83. or, if you prefer 3.3.3 over 2.7.6,
  84. $ pyenv global 3.3.3 2.7.6
  85. $ pyenv versions
  86. system
  87. * 2.7.6 (set by /Users/yyuu/.pyenv/version)
  88. * 3.3.3 (set by /Users/yyuu/.pyenv/version)
  89. venv27
  90. $ python --version
  91. Python 3.3.3
  92. $ python2.7 --version
  93. Python 2.7.6
  94. $ python3.3 --version
  95. Python 3.3.3
  96. ## `pyenv shell`
  97. Sets a shell-specific Python version by setting the `PYENV_VERSION`
  98. environment variable in your shell. This version overrides
  99. application-specific versions and the global version.
  100. $ pyenv shell pypy-2.2.1
  101. When run without a version number, `pyenv shell` reports the current
  102. value of `PYENV_VERSION`. You can also unset the shell version:
  103. $ pyenv shell --unset
  104. Note that you'll need pyenv's shell integration enabled (step 3 of
  105. the installation instructions) in order to use this command. If you
  106. prefer not to use shell integration, you may simply set the
  107. `PYENV_VERSION` variable yourself:
  108. $ export PYENV_VERSION=pypy-2.2.1
  109. ### `pyenv shell` (advanced)
  110. You can specify multiple versions via `PYENV_VERSION` at once.
  111. Let's say if you have two versions of 2.7.6 and 3.3.3. If you prefer 2.7.6 over 3.3.3,
  112. $ pyenv shell 2.7.6 3.3.3
  113. $ pyenv versions
  114. system
  115. * 2.7.6 (set by PYENV_VERSION environment variable)
  116. * 3.3.3 (set by PYENV_VERSION environment variable)
  117. $ python --version
  118. Python 2.7.6
  119. $ python2.7 --version
  120. Python 2.7.6
  121. $ python3.3 --version
  122. Python 3.3.3
  123. or, if you prefer 3.3.3 over 2.7.6,
  124. $ pyenv shell 3.3.3 2.7.6
  125. $ pyenv versions
  126. system
  127. * 2.7.6 (set by PYENV_VERSION environment variable)
  128. * 3.3.3 (set by PYENV_VERSION environment variable)
  129. venv27
  130. $ python --version
  131. Python 3.3.3
  132. $ python2.7 --version
  133. Python 2.7.6
  134. $ python3.3 --version
  135. Python 3.3.3
  136. ## `pyenv install`
  137. Install a Python version (using `python-build`).
  138. Usage: pyenv install [-f] [-kvp] <version>
  139. pyenv install [-f] [-kvp] <definition-file>
  140. pyenv install -l|--list
  141. -l/--list List all available versions
  142. -f/--force Install even if the version appears to be installed already
  143. python-build options:
  144. -k/--keep Keep source tree in $PYENV_BUILD_ROOT after installation
  145. (defaults to $PYENV_ROOT/sources)
  146. -v/--verbose Verbose mode: print compilation status to stdout
  147. -p/--patch Apply a patch from stdin before building
  148. -g/--debug Build a debug version
  149. ## `pyenv uninstall`
  150. Uninstall a specific Python version.
  151. Usage: pyenv uninstall [-f|--force] <version>
  152. -f Attempt to remove the specified version without prompting
  153. for confirmation. If the version does not exist, do not
  154. display an error message.
  155. ## `pyenv rehash`
  156. Installs shims for all Python binaries known to pyenv (i.e.,
  157. `~/.pyenv/versions/*/bin/*`). Run this command after you install a new
  158. version of Python, or install a package that provides binaries.
  159. $ pyenv rehash
  160. ## `pyenv version`
  161. Displays the currently active Python version, along with information on
  162. how it was set.
  163. $ pyenv version
  164. 2.7.6 (set by /home/yyuu/.pyenv/version)
  165. ## `pyenv versions`
  166. Lists all Python versions known to pyenv, and shows an asterisk next to
  167. the currently active version.
  168. $ pyenv versions
  169. 2.5.6
  170. 2.6.8
  171. * 2.7.6 (set by /home/yyuu/.pyenv/version)
  172. 3.3.3
  173. jython-2.5.3
  174. pypy-2.2.1
  175. ## `pyenv which`
  176. Displays the full path to the executable that pyenv will invoke when
  177. you run the given command.
  178. $ pyenv which python3.3
  179. /home/yyuu/.pyenv/versions/3.3.3/bin/python3.3
  180. ## `pyenv whence`
  181. Lists all Python versions with the given command installed.
  182. $ pyenv whence 2to3
  183. 2.6.8
  184. 2.7.6
  185. 3.3.3
  186. ## `pyenv install`
  187. Part of [Python-build](https://github.com/yyuu/pyenv/tree/master/plugins/python-build), this installs versions of python
  188. $ pyenv install 2.7.6
  189. $ pyenv install 2.6.8
  190. $ pyenv versions
  191. system
  192. 2.6.8
  193. * 2.7.6 (set by /home/yyuu/.pyenv/version)
  194. ## `pyenv install --list`
  195. List available remote versions of Python, including Anaconda, Jython, pypy, and stackless
  196. $ pyenv install --list