Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

287 linhas
7.4 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. -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. ## `pyenv uninstall`
  151. Uninstall a specific Python version.
  152. Usage: pyenv uninstall [-f|--force] <version>
  153. -f Attempt to remove the specified version without prompting
  154. for confirmation. If the version does not exist, do not
  155. display an error message.
  156. ## `pyenv rehash`
  157. Installs shims for all Python binaries known to pyenv (i.e.,
  158. `~/.pyenv/versions/*/bin/*`). Run this command after you install a new
  159. version of Python, or install a package that provides binaries.
  160. $ pyenv rehash
  161. ## `pyenv version`
  162. Displays the currently active Python version, along with information on
  163. how it was set.
  164. $ pyenv version
  165. 2.7.6 (set by /home/yyuu/.pyenv/version)
  166. ## `pyenv versions`
  167. Lists all Python versions known to pyenv, and shows an asterisk next to
  168. the currently active version.
  169. $ pyenv versions
  170. 2.5.6
  171. 2.6.8
  172. * 2.7.6 (set by /home/yyuu/.pyenv/version)
  173. 3.3.3
  174. jython-2.5.3
  175. pypy-2.2.1
  176. ## `pyenv which`
  177. Displays the full path to the executable that pyenv will invoke when
  178. you run the given command.
  179. $ pyenv which python3.3
  180. /home/yyuu/.pyenv/versions/3.3.3/bin/python3.3
  181. ## `pyenv whence`
  182. Lists all Python versions with the given command installed.
  183. $ pyenv whence 2to3
  184. 2.6.8
  185. 2.7.6
  186. 3.3.3
  187. ## `pyenv install`
  188. Part of [Python-build](https://github.com/yyuu/pyenv/tree/master/plugins/python-build), this installs versions of python
  189. $ pyenv install 2.7.6
  190. $ pyenv install 2.6.8
  191. $ pyenv versions
  192. system
  193. 2.6.8
  194. * 2.7.6 (set by /home/yyuu/.pyenv/version)
  195. ## `pyenv install --list`
  196. List available remote versions of Python, including Anaconda, Jython, pypy, and stackless
  197. $ pyenv install --list