Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

276 lignes
10 KiB

il y a 12 ans
il y a 8 ans
il y a 9 ans
il y a 12 ans
il y a 12 ans
il y a 12 ans
il y a 10 ans
il y a 12 ans
il y a 10 ans
il y a 9 ans
il y a 10 ans
il y a 10 ans
il y a 10 ans
il y a 10 ans
il y a 10 ans
il y a 12 ans
il y a 12 ans
il y a 10 ans
il y a 12 ans
il y a 9 ans
il y a 12 ans
il y a 11 ans
il y a 11 ans
il y a 9 ans
il y a 10 ans
il y a 11 ans
il y a 9 ans
il y a 11 ans
il y a 10 ans
il y a 9 ans
il y a 10 ans
il y a 11 ans
il y a 11 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 11 ans
il y a 11 ans
il y a 11 ans
il y a 12 ans
il y a 9 ans
il y a 12 ans
il y a 12 ans
il y a 9 ans
il y a 12 ans
  1. # pyenv-virtualenv
  2. [![Join the chat at https://gitter.im/yyuu/pyenv-virtualenv](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/yyuu/pyenv-virtualenv?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
  3. [![Build Status](https://travis-ci.org/pyenv/pyenv-virtualenv.svg?branch=master)](https://travis-ci.org/pyenv/pyenv-virtualenv)
  4. pyenv-virtualenv is a [pyenv](https://github.com/pyenv/pyenv) plugin
  5. that provides features to manage virtualenvs and conda environments
  6. for Python on UNIX-like systems.
  7. (NOTICE: If you are an existing user of [virtualenvwrapper](http://pypi.python.org/pypi/virtualenvwrapper)
  8. and you love it, [pyenv-virtualenvwrapper](https://github.com/pyenv/pyenv-virtualenvwrapper) may help you
  9. (additionally) to manage your virtualenvs.)
  10. ## Installation
  11. ### Installing as a pyenv plugin
  12. This will install the latest development version of pyenv-virtualenv into
  13. the `$(pyenv root)/plugins/pyenv-virtualenv` directory.
  14. **Important note:** If you installed pyenv into a non-standard directory, make
  15. sure that you clone this repo into the 'plugins' directory of wherever you
  16. installed into.
  17. From inside that directory you can:
  18. - Check out a specific release tag.
  19. - Get the latest development release by running `git pull` to download the
  20. latest changes.
  21. 1. **Check out pyenv-virtualenv into plugin directory**
  22. ```bash
  23. git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
  24. ```
  25. For the Fish shell:
  26. ```fish
  27. git clone https://github.com/pyenv/pyenv-virtualenv.git (pyenv root)/plugins/pyenv-virtualenv
  28. ```
  29. 2. (OPTIONAL) **Add `pyenv virtualenv-init` to your shell** to enable auto-activation of virtualenvs. This is entirely optional but pretty useful. See "Activate virtualenv" below.
  30. ```bash
  31. echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
  32. ```
  33. **Fish shell note**: Add this to your `~/.config/fish/config.fish`
  34. ```fish
  35. status --is-interactive; and pyenv virtualenv-init - | source
  36. ```
  37. **Zsh note**: Modify your `~/.zshrc` file instead of `~/.bashrc`.
  38. 3. **Restart your shell to enable pyenv-virtualenv**
  39. ```bash
  40. exec "$SHELL"
  41. ```
  42. ### Installing with Homebrew (for macOS users)
  43. macOS users can install pyenv-virtualenv with the
  44. [Homebrew](https://brew.sh) package manager.
  45. This will give you access to the `pyenv-virtualenv` command. If you have pyenv
  46. installed, you will also be able to use the `pyenv virtualenv` command.
  47. *This is the recommended method of installation if you installed pyenv
  48. with Homebrew.*
  49. ```sh
  50. brew install pyenv-virtualenv
  51. ```
  52. Or, if you would like to install the latest development release:
  53. ```sh
  54. brew install --HEAD pyenv-virtualenv
  55. ```
  56. After installation, you'll still need to do
  57. [Pyenv shell setup steps](https://github.com/pyenv/pyenv#basic-github-checkout)
  58. then add
  59. ```sh
  60. eval "$(pyenv virtualenv-init -)"
  61. ```
  62. to your shell's `.rc` file (as stated in the caveats). You'll only ever have to do this once.
  63. ## Usage
  64. ### Using `pyenv virtualenv` with pyenv
  65. To create a virtualenv for the Python version used with pyenv, run
  66. `pyenv virtualenv`, specifying the Python version you want and the name
  67. of the virtualenv directory. For example,
  68. ```sh
  69. pyenv virtualenv 2.7.10 my-virtual-env-2.7.10
  70. ```
  71. will create a virtualenv based on Python 2.7.10 under `$(pyenv root)/versions` in a
  72. folder called `my-virtual-env-2.7.10`.
  73. `pyenv virtualenv` forwards any options to the underlying command that actually
  74. creates the virtual environment (`conda`, `virtualenv`, or `python -m venv`).
  75. See the output of `pyenv virtualenv --help` for details.
  76. ### Create virtualenv from current version
  77. If there is only one argument given to `pyenv virtualenv`, the virtualenv will
  78. be created with the given name based on the current pyenv Python version.
  79. ```sh
  80. $ pyenv version
  81. 3.4.3 (set by /home/yyuu/.pyenv/version)
  82. $ pyenv virtualenv venv34
  83. ```
  84. ### List existing virtualenvs
  85. `pyenv virtualenvs` shows you the list of existing virtualenvs and `conda` environments.
  86. ```sh
  87. $ pyenv shell venv34
  88. $ pyenv virtualenvs
  89. miniconda3-3.9.1 (created from /home/yyuu/.pyenv/versions/miniconda3-3.9.1)
  90. miniconda3-3.9.1/envs/myenv (created from /home/yyuu/.pyenv/versions/miniconda3-3.9.1)
  91. 2.7.10/envs/my-virtual-env-2.7.10 (created from /home/yyuu/.pyenv/versions/2.7.10)
  92. 3.4.3/envs/venv34 (created from /home/yyuu/.pyenv/versions/3.4.3)
  93. my-virtual-env-2.7.10 (created from /home/yyuu/.pyenv/versions/2.7.10)
  94. * venv34 (created from /home/yyuu/.pyenv/versions/3.4.3)
  95. ```
  96. There are two entries for each virtualenv, and the shorter one is just a symlink.
  97. ### Activate virtualenv
  98. Some external tools (e.g. [jedi](https://github.com/davidhalter/jedi)) might
  99. require you to `activate` the virtualenv and `conda` environments.
  100. If `eval "$(pyenv virtualenv-init -)"` is configured in your shell, `pyenv-virtualenv` will automatically activate/deactivate virtualenvs on entering/leaving directories which contain a `.python-version` file that contains the name of a valid virtual environment as shown in the output of `pyenv virtualenvs` (e.g., `venv34` or `3.4.3/envs/venv34` in example above) . `.python-version` files are used by pyenv to denote local Python versions and can be created and deleted with the [`pyenv local`](https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-local) command.
  101. You can also activate and deactivate a pyenv virtualenv manually:
  102. ```sh
  103. pyenv activate <name>
  104. pyenv deactivate
  105. ```
  106. ### Delete existing virtualenv
  107. Removing the directories in `$(pyenv root)/versions` and `$(pyenv root)/versions/{version}/envs` will delete the virtualenv, or you can run:
  108. ```sh
  109. pyenv uninstall my-virtual-env
  110. ```
  111. You can also delete existing virtualenvs by using `virtualenv-delete` command, e.g. you can run:
  112. ```sh
  113. pyenv virtualenv-delete my-virtual-env
  114. ```
  115. This will delete virtualenv called `my-virtual-env`.
  116. ### virtualenv and venv
  117. There is a [venv](http://docs.python.org/3/library/venv.html) module available
  118. for CPython 3.3 and newer.
  119. It provides an executable module `venv` which is the successor of `virtualenv`
  120. and distributed by default.
  121. `pyenv-virtualenv` uses `python -m venv` if it is available and the `virtualenv`
  122. command is not available.
  123. ### Anaconda and Miniconda
  124. You can manage `conda` environments by `conda create` as same manner as standard Anaconda/Miniconda installations.
  125. To use those environments, you can use `pyenv activate` and `pyenv deactivate`.
  126. ```sh
  127. $ pyenv version
  128. miniconda3-3.9.1 (set by /home/yyuu/.pyenv/version)
  129. $ conda env list
  130. # conda environments:
  131. #
  132. myenv /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv
  133. root * /home/yyuu/.pyenv/versions/miniconda3-3.9.1
  134. $ pyenv activate miniconda3-3.9.1/envs/myenv
  135. discarding /home/yyuu/.pyenv/versions/miniconda3-3.9.1/bin from PATH
  136. prepending /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv/bin to PATH
  137. $ python --version
  138. Python 3.4.3 :: Continuum Analytics, Inc.
  139. $ pyenv deactivate
  140. discarding /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv/bin from PATH
  141. ```
  142. If `conda` is available, `pyenv virtualenv` will use it to create environment by `conda create`.
  143. ```sh
  144. $ pyenv version
  145. miniconda3-3.9.1 (set by /home/yyuu/.pyenv/version)
  146. $ pyenv virtualenv myenv2
  147. $ conda env list
  148. # conda environments:
  149. #
  150. myenv /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv
  151. myenv /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv2
  152. root * /home/yyuu/.pyenv/versions/miniconda3-3.9.1
  153. ```
  154. You can use version like `miniconda3-3.9.1/envs/myenv` to specify `conda` environment as a version in pyenv.
  155. ```sh
  156. $ pyenv version
  157. miniconda3-3.9.1 (set by /home/yyuu/.pyenv/version)
  158. $ pyenv shell miniconda3-3.9.1/envs/myenv
  159. $ which python
  160. /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv/bin/python
  161. ```
  162. ### Special environment variables
  163. You can set certain environment variables to control pyenv-virtualenv.
  164. * `PYENV_VIRTUALENV_CACHE_PATH`, if set, specifies a directory to use for
  165. caching downloaded package files.
  166. * `VIRTUALENV_VERSION`, if set, forces pyenv-virtualenv to install the desired
  167. version of virtualenv. If `virtualenv` has not been installed,
  168. pyenv-virtualenv will try to install the given version of virtualenv.
  169. * `GET_PIP`, if set and `venv` is preferred over `virtualenv`,
  170. use `get_pip.py` from the specified location.
  171. * `GET_PIP_URL`, if set and `venv` is preferred over
  172. `virtualenv`, download `get_pip.py` from the specified URL.
  173. * `PIP_VERSION`, if set and `venv` is preferred
  174. over `virtualenv`, install the specified version of pip.
  175. * `PYENV_VIRTUALENV_VERBOSE_ACTIVATE`, if set, shows some verbose outputs on activation and deactivation
  176. * `PYENV_VIRTUALENV_PROMPT`, if set, allows users to customize how `pyenv-virtualenv` modifies their shell prompt. The default prompt ("(venv)") is overwritten with any user-specified text. Specify the location of the virtual environment name with the string `{venv}`. For example, the default prompt string would be `({venv})`.
  177. ## Version History
  178. See [CHANGELOG.md](CHANGELOG.md).
  179. ### License
  180. [(The MIT License)](LICENSE)
  181. * Copyright (c) 2015 Yamashita, Yuu
  182. Permission is hereby granted, free of charge, to any person obtaining
  183. a copy of this software and associated documentation files (the
  184. "Software"), to deal in the Software without restriction, including
  185. without limitation the rights to use, copy, modify, merge, publish,
  186. distribute, sublicense, and/or sell copies of the Software, and to
  187. permit persons to whom the Software is furnished to do so, subject to
  188. the following conditions:
  189. The above copyright notice and this permission notice shall be
  190. included in all copies or substantial portions of the Software.
  191. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  192. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  193. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  194. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  195. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  196. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  197. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.