1. Non-standard Library
1.1 virtualenv
virtualenv is a very popular tool for creating isolated python libraries environments. I strongly recommend you learn about it, because it is very practical and widely used; many people use it to set up python development environments. The other tools below are mainly compared against virtualenv to illustrate the differences.
virtualenv installs a series of executable and library files into a directory (for example: env/), and then achieves its purpose by modifying the order of the executable directories (the bin directory) in the PATH environment variable β for example, putting env/bin/ at the front of the PATH environment variable. It then places a python or python3 executable under env/bin/. Because python preferentially searches relative directories close to its own path when it runs, this achieves the goal of preferentially using the libraries directory created by virtualenv. After running activate to enter the virtualenv environment, you can install libraries into the env/ environment with pip.
1.2 pyenv
pyenv is used to create isolated python version environments. For example, you might want to test how your code runs under python2.6, 2.7, 3.3, 3.4, and 3.5 respectively, in which case you need a tool like pyenv to switch python versions quickly. Once the pyenv environment is activated, it puts the values in ~/.pyenv/shims at the front of the PATH environment variable, overriding the default python and pip executable directories. It does not copy executables; it merely uses some script code based on PYENV_VERSION or the .python-version file to decide which python executable to use to run a python program. In addition, you can install multiple python versions with pyenv install.
1.3 pyenv-virtualenv
pyenv-virtualenv, a plugin written by pyenv’s author for pyenv, lets you conveniently use pyenv and virtualenv at the same time. Also, if you are using python 3.3 or above, it will try to use venv instead of virtualenv. Of course, you can also configure pyenv and virtualenv to work together yourself, rather than using pyenv-virtualenv directly.
1.4 virtualenvwrapper
virtualenvwrapper is a series of extensions to virtualenv. It provides command-line tools such as mkvirtualenv and lssitepackages; in particular the workon command-line tool is especially convenient when you need to use multiple virtualenv directories.
1.5 pyenv-virtualenvwrapper
pyenv-virtualenvwrapper is another plugin written by pyenv’s author for pyenv, which conveniently integrates virtualenvwrapper into pyenv.
1.6 pipenv
pipenv, a tool written by Kenneth Reitz, the author of the requests library, aims to merge Pipfile, pip, and virtualenv into a single command-line tool. In practice it is similar to nodejs’s dependency package management tool npm.
2. Standard Library
2.1 pyvenv
pyvenv is a standard tool bundled with python3, but it has been deprecated in python3.6 and replaced by venv (python3 -m venv).
2.2 venv
venv is a command-line tool bundled with python3, started by running python3 -m venv. Also, in some distributions venv needs to be installed separately β for example Ubuntu requires installing python3-venv. venv and virtualenv are very close; the main difference is that it does not need to separately copy the python executable into the corresponding directory. If you do not need to support python2, you can use venv directly. However, as of now the python community still prefers to use virtualenv.
