Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

401 rinda
11 KiB

pirms 3 gadiem
  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 help`](#pyenv-help)
  6. * [`pyenv commands`](#pyenv-commands)
  7. * [`pyenv local`](#pyenv-local)
  8. * [`pyenv global`](#pyenv-global)
  9. * [`pyenv shell`](#pyenv-shell)
  10. * [`pyenv install`](#pyenv-install)
  11. * [`pyenv uninstall`](#pyenv-uninstall)
  12. * [`pyenv rehash`](#pyenv-rehash)
  13. * [`pyenv version`](#pyenv-version)
  14. * [`pyenv versions`](#pyenv-versions)
  15. * [`pyenv which`](#pyenv-which)
  16. * [`pyenv whence`](#pyenv-whence)
  17. * [`pyenv exec`](#pyenv-exec)
  18. * [`pyenv root`](#pyenv-root)
  19. * [`pyenv prefix`](#pyenv-prefix)
  20. * [`pyenv latest`](#pyenv-latest)
  21. * [`pyenv hooks`](#pyenv-hooks)
  22. * [`pyenv shims`](#pyenv-shims)
  23. * [`pyenv init`](#pyenv-init)
  24. * [`pyenv completions`](#pyenv-completions)
  25. ## `pyenv help`
  26. List all available pyenv commands along with a brief description of what they do. Run `pyenv help <command>` for information on a specific command. For full documentation, see: https://github.com/pyenv/pyenv#readme
  27. ## `pyenv commands`
  28. Lists all available pyenv commands.
  29. ## `pyenv local`
  30. Sets a local application-specific Python version by writing the version
  31. name to a `.python-version` file in the current directory. This version
  32. overrides the global version, and can be overridden itself by setting
  33. the `PYENV_VERSION` environment variable or with the `pyenv shell`
  34. command.
  35. $ pyenv local 2.7.6
  36. When run without a version number, `pyenv local` reports the currently
  37. configured local version. You can also unset the local version:
  38. $ pyenv local --unset
  39. Previous versions of pyenv stored local version specifications in a
  40. file named `.pyenv-version`. For backwards compatibility, pyenv will
  41. read a local version specified in an `.pyenv-version` file, but a
  42. `.python-version` file in the same directory will take precedence.
  43. ### `pyenv local` (advanced)
  44. You can specify multiple versions as local Python at once.
  45. 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,
  46. $ pyenv local 2.7.6 3.3.3
  47. $ pyenv versions
  48. system
  49. * 2.7.6 (set by /Users/yyuu/path/to/project/.python-version)
  50. * 3.3.3 (set by /Users/yyuu/path/to/project/.python-version)
  51. $ python --version
  52. Python 2.7.6
  53. $ python2.7 --version
  54. Python 2.7.6
  55. $ python3.3 --version
  56. Python 3.3.3
  57. or, if you prefer 3.3.3 over 2.7.6,
  58. $ pyenv local 3.3.3 2.7.6
  59. $ pyenv versions
  60. system
  61. * 2.7.6 (set by /Users/yyuu/path/to/project/.python-version)
  62. * 3.3.3 (set by /Users/yyuu/path/to/project/.python-version)
  63. venv27
  64. $ python --version
  65. Python 3.3.3
  66. $ python2.7 --version
  67. Python 2.7.6
  68. $ python3.3 --version
  69. Python 3.3.3
  70. ## `pyenv global`
  71. Sets the global version of Python to be used in all shells by writing
  72. the version name to the `~/.pyenv/version` file. This version can be
  73. overridden by an application-specific `.python-version` file, or by
  74. setting the `PYENV_VERSION` environment variable.
  75. $ pyenv global 2.7.6
  76. The special version name `system` tells pyenv to use the system Python
  77. (detected by searching your `$PATH`).
  78. When run without a version number, `pyenv global` reports the
  79. currently configured global version.
  80. ### `pyenv global` (advanced)
  81. You can specify multiple versions as global Python at once.
  82. 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,
  83. $ pyenv global 2.7.6 3.3.3
  84. $ pyenv versions
  85. system
  86. * 2.7.6 (set by /Users/yyuu/.pyenv/version)
  87. * 3.3.3 (set by /Users/yyuu/.pyenv/version)
  88. $ python --version
  89. Python 2.7.6
  90. $ python2.7 --version
  91. Python 2.7.6
  92. $ python3.3 --version
  93. Python 3.3.3
  94. or, if you prefer 3.3.3 over 2.7.6,
  95. $ pyenv global 3.3.3 2.7.6
  96. $ pyenv versions
  97. system
  98. * 2.7.6 (set by /Users/yyuu/.pyenv/version)
  99. * 3.3.3 (set by /Users/yyuu/.pyenv/version)
  100. venv27
  101. $ python --version
  102. Python 3.3.3
  103. $ python2.7 --version
  104. Python 2.7.6
  105. $ python3.3 --version
  106. Python 3.3.3
  107. ## `pyenv shell`
  108. Sets a shell-specific Python version by setting the `PYENV_VERSION`
  109. environment variable in your shell. This version overrides
  110. application-specific versions and the global version.
  111. $ pyenv shell pypy-2.2.1
  112. When run without a version number, `pyenv shell` reports the current
  113. value of `PYENV_VERSION`. You can also unset the shell version:
  114. $ pyenv shell --unset
  115. Note that you'll need pyenv's shell integration enabled (step 3 of
  116. the installation instructions) in order to use this command. If you
  117. prefer not to use shell integration, you may simply set the
  118. `PYENV_VERSION` variable yourself:
  119. $ export PYENV_VERSION=pypy-2.2.1
  120. ### `pyenv shell` (advanced)
  121. You can specify multiple versions via `PYENV_VERSION` at once.
  122. 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,
  123. $ pyenv shell 2.7.6 3.3.3
  124. $ pyenv versions
  125. system
  126. * 2.7.6 (set by PYENV_VERSION environment variable)
  127. * 3.3.3 (set by PYENV_VERSION environment variable)
  128. $ python --version
  129. Python 2.7.6
  130. $ python2.7 --version
  131. Python 2.7.6
  132. $ python3.3 --version
  133. Python 3.3.3
  134. or, if you prefer 3.3.3 over 2.7.6,
  135. $ pyenv shell 3.3.3 2.7.6
  136. $ pyenv versions
  137. system
  138. * 2.7.6 (set by PYENV_VERSION environment variable)
  139. * 3.3.3 (set by PYENV_VERSION environment variable)
  140. venv27
  141. $ python --version
  142. Python 3.3.3
  143. $ python2.7 --version
  144. Python 2.7.6
  145. $ python3.3 --version
  146. Python 3.3.3
  147. ## `pyenv install`
  148. Install a Python version (using [`python-build`](https://github.com/pyenv/pyenv/tree/master/plugins/python-build)).
  149. Usage: pyenv install [-f] [-kvp] <version>
  150. pyenv install [-f] [-kvp] <definition-file>
  151. pyenv install -l|--list
  152. -l/--list List all available versions
  153. -f/--force Install even if the version appears to be installed already
  154. -s/--skip-existing Skip the installation if the version appears to be installed already
  155. python-build options:
  156. -k/--keep Keep source tree in $PYENV_BUILD_ROOT after installation
  157. (defaults to $PYENV_ROOT/sources)
  158. -v/--verbose Verbose mode: print compilation status to stdout
  159. -p/--patch Apply a patch from stdin before building
  160. -g/--debug Build a debug version
  161. To list the all available versions of Python, including Anaconda, Jython, pypy, and stackless, use:
  162. $ pyenv install --list
  163. Then install the desired versions:
  164. $ pyenv install 2.7.6
  165. $ pyenv install 2.6.8
  166. $ pyenv versions
  167. system
  168. 2.6.8
  169. * 2.7.6 (set by /home/yyuu/.pyenv/version)
  170. You can also install the latest version of Python in a specific version line by supplying a prefix instead of a complete name:
  171. $ pyenv install 3.10
  172. See the [`pyenv latest` documentation](#pyenv-latest) for details on prefix resolution.
  173. An older option is to use the `:latest` syntax. For example, to install the latest patch version for Python 3.8 you could do:
  174. pyenv install 3.8:latest
  175. To install the latest major release for Python 3 try:
  176. pyenv install 3:latest
  177. ## `pyenv uninstall`
  178. Uninstall Python versions.
  179. Usage: pyenv uninstall [-f|--force] <version> ...
  180. -f Attempt to remove the specified version without prompting
  181. for confirmation. If the version does not exist, do not
  182. display an error message.
  183. ## `pyenv rehash`
  184. Installs shims for all Python binaries known to pyenv (i.e.,
  185. `~/.pyenv/versions/*/bin/*`). Run this command after you install a new
  186. version of Python, or install a package that provides binaries.
  187. $ pyenv rehash
  188. ## `pyenv version`
  189. Displays the currently active Python version, along with information on
  190. how it was set.
  191. $ pyenv version
  192. 2.7.6 (set by /home/yyuu/.pyenv/version)
  193. ## `pyenv versions`
  194. Lists all Python versions known to pyenv, and shows an asterisk next to
  195. the currently active version.
  196. $ pyenv versions
  197. 2.5.6
  198. 2.6.8
  199. * 2.7.6 (set by /home/yyuu/.pyenv/version)
  200. 3.3.3
  201. jython-2.5.3
  202. pypy-2.2.1
  203. ## `pyenv which`
  204. Displays the full path to the executable that pyenv will invoke when
  205. you run the given command.
  206. $ pyenv which python3.3
  207. /home/yyuu/.pyenv/versions/3.3.3/bin/python3.3
  208. Use --nosystem argument in case when you don't need to search command in the
  209. system environment.
  210. ## `pyenv whence`
  211. Lists all Python versions with the given command installed.
  212. $ pyenv whence 2to3
  213. 2.6.8
  214. 2.7.6
  215. 3.3.3
  216. ## `pyenv exec`
  217. Usage: pyenv exec <command> [arg1 arg2...]
  218. Runs an executable by first preparing PATH so that the selected Python
  219. version's `bin` directory is at the front.
  220. For example, if the currently selected Python version is 3.9.7:
  221. pyenv exec pip install -r requirements.txt
  222. is equivalent to:
  223. PATH="$PYENV_ROOT/versions/3.9.7/bin:$PATH" pip install -r requirements.txt
  224. ## `pyenv root`
  225. Displays the root directory where versions and shims are kept.
  226. $ pyenv root
  227. /home/user/.pyenv
  228. ## `pyenv prefix`
  229. Displays the directories where the given Python versions are installed,
  230. separated by colons. If no version is given, `pyenv prefix` displays the
  231. locations of the currently selected versions.
  232. $ pyenv prefix 3.9.7
  233. /home/user/.pyenv/versions/3.9.7
  234. ## `pyenv latest`
  235. Displays the latest installed or known version with the given prefix
  236. Usage: pyenv latest [-k|--known] [-q|--quiet] <prefix>
  237. -k/--known Select from all known versions instead of installed
  238. -q/--quiet Do not print an error message on resolution failure
  239. Only full prefixes are searched: in the actual name, the given prefix must be followed by a dot or a dash.
  240. Prereleases and versions with specific suffixes (e.g. `-src`) are ignored.
  241. ## `pyenv hooks`
  242. Lists installed hook scripts for a given pyenv command.
  243. Usage: pyenv hooks <command>
  244. ## `pyenv shims`
  245. List existing pyenv shims.
  246. Usage: pyenv shims [--short]
  247. $ pyenv shims
  248. /home/user/.pyenv/shims/2to3
  249. /home/user/.pyenv/shims/2to3-3.9
  250. /home/user/.pyenv/shims/idle
  251. /home/user/.pyenv/shims/idle3
  252. /home/user/.pyenv/shims/idle3.9
  253. /home/user/.pyenv/shims/pip
  254. /home/user/.pyenv/shims/pip3
  255. /home/user/.pyenv/shims/pip3.9
  256. /home/user/.pyenv/shims/pydoc
  257. /home/user/.pyenv/shims/pydoc3
  258. /home/user/.pyenv/shims/pydoc3.9
  259. /home/user/.pyenv/shims/python
  260. /home/user/.pyenv/shims/python3
  261. /home/user/.pyenv/shims/python3.9
  262. /home/user/.pyenv/shims/python3.9-config
  263. /home/user/.pyenv/shims/python3.9-gdb.py
  264. /home/user/.pyenv/shims/python3-config
  265. /home/user/.pyenv/shims/python-config
  266. ## `pyenv init`
  267. Configure the shell environment for pyenv
  268. Usage: eval "$(pyenv init [-|--path] [--no-push-path] [--no-rehash] [<shell>])"
  269. - Initialize shims directory, print PYENV_SHELL variable, completions path
  270. and shell function
  271. --path Print shims path
  272. --no-push-path Do not push shim to the start of PATH if they're already there
  273. --no-rehash Add no rehash command to output
  274. ## `pyenv completions`
  275. Lists available completions for a given pyenv command.
  276. Usage: pyenv completions <command> [arg1 arg2...]