pyenv-virtualenv is a pyenv plugin
that provides a pyenv virtualenv
command to create virtualenvs for Python
on UNIX-like systems.
(NOTICE: If you are an existing user of virtualenvwrapper and you love it, pyenv-virtualenvwrapper may help you (additionally) to manage your virtualenvs.)
This will install the latest development version of pyenv-virtualenv into
the ~/.pyenv/plugins/pyenv-virtualenv
directory.
Important note: If you installed pyenv into a non-standard directory, make sure that you clone this repo into the 'plugins' directory of wherever you installed into.
From inside that directory you can:
- Check out a specific release tag.
- Get the latest development release by running
git pull
to download the latest changes.
-
Check out pyenv-virtualenv into plugin directory
$ git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
-
Add
pyenv virtualenv-init
to your shell to enable activation of virtualenv. This is entirely optional but pretty useful.$ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
Zsh note: Modify your
~/.zshenv
file instead of~/.bash_profile
. Pyenv note: You may also need to add 'eval "$(pyenv init -)"' to your profile if you haven't done so already. -
Restart your shell to enable pyenv-virtualenv
$ exec "$SHELL"
Mac OS X users can install pyenv-virtualenv with the
Homebrew package manager.
This will give you access to the pyenv-virtualenv
command. If you have pyenv
installed, you will also be able to use the pyenv virtualenv
command.
This is the recommended method of installation if you installed pyenv with Homebrew.
$ brew install pyenv-virtualenv
Or, if you would like to install the latest development release:
$ brew install --HEAD pyenv-virtualenv
After installation, you'll still need to add eval "$(pyenv virtualenv-init -)"
to your profile (as stated in the caveats). You'll only ever have to do
this once.
To create a virtualenv for the Python version used with pyenv, run
pyenv virtualenv
, specifying the Python version you want and the name
of the virtualenv directory. For example,
$ pyenv virtualenv 2.7.7 my-virtual-env-2.7.7
will create a virtualenv based on Python 2.7.7 under ~/.pyenv/versions
in a
folder called my-virtual-env-2.7.7
.
If there is only one argument given to pyenv virtualenv
, the virtualenv will
be created with the given name based on the current pyenv Python version.
$ pyenv version
3.4.2 (set by /home/yyuu/.pyenv/version)
$ pyenv virtualenv venv34
pyenv virtualenvs
shows you the list of existing virtualenvs:
$ pyenv shell venv27
$ pyenv virtualenvs
* venv27 (created from /home/yyuu/.pyenv/versions/2.7.7)
venv34 (created from /home/yyuu/.pyenv/versions/3.4.1)
Some external tools (e.g. jedi) might
require you to activate
the virtualenv.
pyenv-virtualenv
will automatically activate/deactivate the virtualenv if
the eval "$(pyenv virtualenv-init -)"
is properly configured in your shell.
You can also activate and deactivate a pyenv virtualenv manually:
pyenv activate <name>
pyenv deactivate
Removing the directory in ~/.pyenv/versions
will delete the virtualenv, or you can run:
pyenv uninstall my-virtual-env
There is a venv module available
for CPython 3.3 and newer.
It provides a command-line tool pyvenv
which is the successor of virtualenv
and distributed by default.
pyenv-virtualenv
uses pyvenv
if it is available and the virtualenv
command is not available.
You can set certain environment variables to control pyenv-virtualenv.
PYENV_VIRTUALENV_CACHE_PATH
, if set, specifies a directory to use for caching downloaded package files.VIRTUALENV_VERSION
, if set, forces pyenv-virtualenv to install the desired version of virtualenv. Ifvirtualenv
has not been installed, pyenv-virtualenv will try to install the given version of virtualenv.EZ_SETUP
andGET_PIP
, if set andpyvenv
is preferred overvirtualenv
, useez_setup.py
andget_pip.py
from the specified location.EZ_SETUP_URL
andGET_PIP_URL
, if set andpyvenv
is preferred overvirtualenv
, downloadez_setup.py
andget_pip.py
from the specified URL.SETUPTOOLS_VERSION
andPIP_VERSION
, if set andpyvenv
is preferred overvirtualenv
, install the specified version of setuptools and pip.
- Ignore errors from
pyenv-version-name
since it might fail if there is configuration error (pyenv/pyenv#291) - The shell version set in
activate
should be unset indeactivate
(#61) - Anaconda has
activate
script nevertheless it is not a virtual environment (#65)
- Stop creating after
ensurepip
since it has done byensurepip
itself - Suppress some useless warnings from
pyenv virtualenv-init
- Fix warnings from
shellcheck
to improve support for POSIX sh (#40) - Do not allow whitespace in
VIRTUALENV_NAME
(#44) - Should not persist
PYENV_DEACTIVATE
after automatic deactivation (#47, #48)
- Display information on auto-(de)?activation
- Support manual (de)?activation with auto-activation enabled (#32, #34)
- Exit as error when (de)?activation failed
- Use https://bootstrap.pypa.io/ to install setuptools and pip
- Create backup of original virtualenv within
$(pyenv root)/versions
when--upgrade
- Fix incompatibility issue of
pyenv activate
andpyenv deactivate
(#26) - Workaround for the issue with pyenv-which-ext (#26)
- Add
pyenv virtualenv-init
to enable auto-activation feature (#24) - Create symlinks for executables with version suffix (pyenv/pyenv#182)
- Use new style GH raw url to avoid redirects (raw.github.com -> raw.githubusercontent.com)
- Repaired virtualenv activation and deactivation for the fish shell (#23)
- Display error if
pyenv activate
was invoked as a command - Fix completion of
pyenv activate
(#15) - Use
virtualenv
instead ofpyvenv
if-p
has given (pyenv/pyenv#158)
- Add
activate
anddeactivate
to makepyenv-virtualenv
work with jedi (#9) - Use
ensurepip
to installpip
if it is available - Unset
PIP_REQUIRE_VENV
to avoid problem on the installation ofvirtualenv
(#10) - Add tests
- Fix install script
- Support environment variables of
EZ_SETUP
andGET_PIP
. - Support a short option
-p
ofvirtualenv
.
- Use latest release of setuptools and pip if the version not given via environment variables.
- Removed bundled
virtualenv.py
script. Now pyenv-virtualenv installsvirtualenv
package into source version and then use it. - On Python 3.3+, use
pyvenv
as virtualenv command ifvirtualenv
is not available. - Install setuptools and pip into environments created by
pyvenv
.
- Add
pyenv virtualenvs
to list all virtualenv versions. - EXPERIMENTAL: Add
--upgrade
option to re-create virtualenv with migrating packages
- Remove
python-virtualenv
which was no longer used. - Change the installation path of the
virtualenv.py
script. (./libexec
->./libexec/pyenv-virtualenv/${VIRTUALENV_VERSION}
) - Download
virtualenv.py
if desired version has not been installed.
- Display virtualenv information in
--help
and--version
- Update virtualenv version; 1.8.4 -> 1.9.1
- Rename the project;
s/python-virtualenv/pyenv-virtualenv/g
- The
pyenv-virtualenv
script is not depending onpython-virtualenv
now.python-virtualenv
will left for compatibility and will not continue for future releases. - Update virtualenv version; 1.8.2 -> 1.8.4
- Add pyenv 0.2.x (rbenv 0.4.x) style help messages.
- Create virtualenv with exact name of python executables.
- Changed command-line options of python-virtualenv. First argument should be a path to the python executable.
- Add install script.
- Initial public release.
(The MIT License)
- Copyright (c) 2013 Yamashita, Yuu
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.