|
| 1 | +title: Virtual environments (virtualenvs) |
| 2 | +category: page |
| 3 | +slug: virtual-environments-virtualenvs-venvs |
| 4 | +sortorder: 0217 |
| 5 | +toc: False |
| 6 | +sidebartitle: Virtualenvs |
| 7 | +meta: Virtual environments (virtualenvs) provide dependency isolation for your projects from external libraries. |
| 8 | + |
| 9 | + |
| 10 | +# Virtual environments (virtualenvs) |
| 11 | +Virtual environments, implemented by the library virtualenv and venv |
| 12 | +(added to Python standard library in Python 3.3 via |
| 13 | +[PEP 405](https://www.python.org/dev/peps/pep-0405/)), separate project |
| 14 | +dependencies, such as the [Django](/django.html) library code, |
| 15 | +from your code projects. For example, if you have three projects, |
| 16 | +one that uses Django 1.7, another that uses Django 2.0 and another project |
| 17 | +that does not use Django at all, you will have three virtualenvs that |
| 18 | +each contain those dependencies separated from each other. |
| 19 | + |
| 20 | + |
| 21 | +## How do virtualenvs work? |
| 22 | +Virtualenv provides dependency isolation for Python projects. A |
| 23 | +virtualenv creates a separate copy of the Python installation that is |
| 24 | +clean of existing code libraries and provides a directory for new |
| 25 | +[application dependencies](/application-dependencies.html) on a |
| 26 | +per-project basis. A programmer can technically use a virtualenv for many |
| 27 | +projects at once but that is not consider to be a good practice. |
| 28 | + |
| 29 | + |
| 30 | +### Virtual environment resources |
| 31 | +* [Package management in Python 2 or 3 (Linux and Mac) with virtualenv or venv](http://aaronsnitzer.com/writing/2016/04/27/virtualenv-and-pyvenv-beginner-tutorial.html) |
| 32 | + |
| 33 | +* [There’s no magic: virtualenv edition](https://www.recurse.com/blog/14-there-is-no-magic-virtualenv-edition) |
| 34 | + |
| 35 | +* [Virtual environments dymystified](https://meribold.github.io/python/2018/02/13/virtual-environments-9487/) |
| 36 | + |
| 37 | +* [What is the relationship between virtualenv and pyenv?](https://stackoverflow.com/questions/29950300/what-is-the-relationship-between-virtualenv-and-pyenv) |
| 38 | + |
| 39 | +* [Setting up Python on a Unix machine (with pyenv and direnv)](https://mike.place/2017/python-pyenv/) |
| 40 | + |
| 41 | +* [venv — Create Virtual Environments](https://pymotw.com/3/venv/) |
| 42 | + |
| 43 | +* [Python development environment, 2018 edition](https://jacobian.org/writing/python-environment-2018/) |
| 44 | + |
0 commit comments