pyenv-virtualenv
Create isolated Python environments
TLDR
Create a new Python 3.6.6 virtual environment
List all existing virtual environments
Activate a virtual environment
Deactivate the virtual environment
SYNOPSIS
pyenv virtualenv [options]
pyenv activate
pyenv deactivate
PARAMETERS
python-version
Specifies the Python version to use for creating the virtual environment. This should be a Python version managed by pyenv (e.g., 3.8.12, system).
virtualenv-name
The name of the virtual environment to create or activate.
--no-setuptools
Do not install setuptools in the virtualenv.
--no-pip
Do not install pip in the virtualenv.
--prompt
Set a custom prompt prefix for the virtualenv.
-f, --force
Force creation of virtualenv even if it already exists (overwrite).
DESCRIPTION
The pyenv-virtualenv plugin seamlessly integrates virtualenv management with pyenv. It allows you to create and manage virtual environments based on specific Python versions managed by pyenv. Instead of activating virtualenvs separately, this plugin automatically activates the appropriate virtual environment when you switch to a directory containing a .python-version file that specifies the virtualenv's name or when you explicitly select a virtualenv using pyenv local or pyenv global.
Key features include easy creation, activation, and deactivation of virtual environments; automatic virtualenv activation based on directory context; and integration with existing pyenv workflows. This simplifies Python project management by ensuring that each project has its own isolated set of dependencies managed by a virtualenv, using your pyenv installed python versions.
CAVEATS
Requires pyenv to be installed and configured correctly. Virtualenv activation relies on pyenv shims. If you're experiencing issues, ensure that pyenv init is correctly configured in your shell's startup file (e.g., .bashrc, .zshrc).
ACTIVATION BEHAVIOR
When you cd into a directory containing a .python-version file that specifies a virtualenv managed by pyenv-virtualenv, the virtual environment is automatically activated. Similarly, if you use pyenv local
DEACTIVATION
To deactivate the current virtual environment, simply use the pyenv deactivate command. This will return you to the base Python environment managed by pyenv.
HISTORY
pyenv-virtualenv was created to extend pyenv's capabilities by adding seamless virtualenv management. It evolved to address the common workflow of creating, activating, and deactivating virtual environments for different Python projects. The plugin automates the activation/deactivation process by leveraging pyenv's shims and version management capabilities.
SEE ALSO
pyenv(1), virtualenv(1)