A bit of light over the usage of virtualenv, pip, venv, pyvenv and pipenv.
- Published: January 15, 2019
Virtual environments has evolved and many packages and different approaches has appeared in last years to solve the same situation for isolating each project set of dependencies.
We will take a look at the different alternatives and how it evolved to try to make it clear the confusion caused by all the similar project names.
First of all, let’s see some useful concepts.
What is a Virtual environment?
A cooperatively isolated runtime environment that allows Python users and applications to install and upgrade Python distribution packages without interfering with the behaviour of other Python applications running on the same system.
What is Pip?
A tool for installing Python packages. 1
It is recommended by The Python Packaging Authority (PyPA), a working group that maintains many of the relevant projects in Python packaging. 2
Following is a list of the recommended ways of handling virtual environments for each Python version to see how they relate to each other:
- Before Python 3.3:
- Ian Bicking’s virtualenv package
- virtualenvwrapper is a set of extensions to Ian Bicking’s virtualenv tool.
- Python 3.3:
- recommends pyvenv script
- a subset of virtualenv was integrated into the standard library under the venv module
- Python 3.6: venv module
pyvenvto avoid confusion as to what Python interpreter pyvenv is connected to and thus what Python interpreter will be used by the virtual environment 3
- recommends: python3 -m venv /path/to/new/virtual/environment
- In Python
sys.pathfor the named module and execute its contents as the
Note that this is a raw summary mostly based in recommendations of the official docs, you may still use any of them.
Nowadays there is also the pipenv project which is a more integral
approach to handle not only virtual environments but also
Pipfiles, and pip. It will create virtualenvs at
Pipfile and Pipfile.lock are a replacement for the existing standard pip’s requirements.txt file 5 which provides more control over package’s versions.
- PEP 405 – Python Virtual Environments: https://www.python.org/dev/peps/pep-0405/
- virtualenv package: https://virtualenv.pypa.io/
- pipenv project: https://github.com/pypa/pipenv
- virtualenvwrapper: https://virtualenvwrapper.readthedocs.io/
- pipenv: https://github.com/pypa/pipenv
- Managing application dependencies: https://packaging.python.org/tutorials/managing-dependencies/
- The PyPA recommended tool for installing Python packages. https://pip.pypa.io/en/stable/ [return]
- https://www.pypa.io/en/latest/ [return]
- https://docs.python.org/dev/whatsnew/3.6.html#deprecated-features [return]
- https://docs.python.org/3/using/cmdline.html#cmdoption-m [return]
- https://github.com/pypa/pipfile [return]