virtualenv#
Instead of the built-in venv
module, virtual environments can also be managed with the PyPI package virtualenv. It offers some additional features and is for instance used by pipenv
and poetry
.
Usage#
The syntax to manage virtual environments is similar to venv
.
$ virtualenv .venv # create new virtual environment .venv
$ source .venv/bin/activate # activate the virtual environment .venv
$ deactivate # deactivate the current virtual environment
When juggling multiple Python versions, you can specify the python executable for the virtual environment.
$ virtualenv -p python3.11 .venv # create .venv for the given python interpreter