Expert Python Programming(Third Edition)
上QQ阅读APP看书,第一时间看更新

venv versus virtualenv

virtualenv was one of the most popular tools to create lightweight virtual environments long before the creation of the pyenv standard library module. Its name simply stands for virtual environment. It's not a part of the standard Python distribution, so it needs to be obtained using pip. If you want to use it, it is one of the packages that is worth installing system-wide (using sudo on Linux and UNIX-based systems).

I would recommend using the venv module instead of virtualenv whenever it is possible. This should be your default choice for projects targeting Python versions 3.4 and higher. Using venv in Python 3.3 may be a little inconvenient due to the lack of built-in support for setuptools and pip. For projects targeting a wider spectrum of Python runtimes (including alternative interpreters and 2.x branch), it seems that virtualenv is the best choice.

In the next section, we'll take a look at system-level environment isolation.