Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

278 строки
7.3 KiB

10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
  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`](https://github.com/pyenv/pyenv/tree/master/plugins/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. -s/--skip-existing Skip the installation if the version appears to be installed already
  144. python-build options:
  145. -k/--keep Keep source tree in $PYENV_BUILD_ROOT after installation
  146. (defaults to $PYENV_ROOT/sources)
  147. -v/--verbose Verbose mode: print compilation status to stdout
  148. -p/--patch Apply a patch from stdin before building
  149. -g/--debug Build a debug version
  150. To list the all available versions of Python, including Anaconda, Jython, pypy, and stackless, use:
  151. $ pyenv install --list
  152. Then install the desired versions:
  153. $ pyenv install 2.7.6
  154. $ pyenv install 2.6.8
  155. $ pyenv versions
  156. system
  157. 2.6.8
  158. * 2.7.6 (set by /home/yyuu/.pyenv/version)
  159. ## `pyenv uninstall`
  160. Uninstall a specific Python version.
  161. Usage: pyenv uninstall [-f|--force] <version>
  162. -f Attempt to remove the specified version without prompting
  163. for confirmation. If the version does not exist, do not
  164. display an error message.
  165. ## `pyenv rehash`
  166. Installs shims for all Python binaries known to pyenv (i.e.,
  167. `~/.pyenv/versions/*/bin/*`). Run this command after you install a new
  168. version of Python, or install a package that provides binaries.
  169. $ pyenv rehash
  170. ## `pyenv version`
  171. Displays the currently active Python version, along with information on
  172. how it was set.
  173. $ pyenv version
  174. 2.7.6 (set by /home/yyuu/.pyenv/version)
  175. ## `pyenv versions`
  176. Lists all Python versions known to pyenv, and shows an asterisk next to
  177. the currently active version.
  178. $ pyenv versions
  179. 2.5.6
  180. 2.6.8
  181. * 2.7.6 (set by /home/yyuu/.pyenv/version)
  182. 3.3.3
  183. jython-2.5.3
  184. pypy-2.2.1
  185. ## `pyenv which`
  186. Displays the full path to the executable that pyenv will invoke when
  187. you run the given command.
  188. $ pyenv which python3.3
  189. /home/yyuu/.pyenv/versions/3.3.3/bin/python3.3
  190. ## `pyenv whence`
  191. Lists all Python versions with the given command installed.
  192. $ pyenv whence 2to3
  193. 2.6.8
  194. 2.7.6
  195. 3.3.3