Application-level environment isolation
Python has built-in support for creating virtual environments. It comes in the form of a venv
module that can be invoked directly from your system shell. To create a new virtual environment, simply use the following command:
$ python3.9 -m venv <env-name>
Here, env-name
should be replaced with the desired name for the new environment (it can also be an absolute path). Note how we used the python3.9
command instead of plain python3
. That's because depending on the environment, python3
may be linked to different interpreter versions and it is always better to be very explicit about the Python version when creating new virtual environments. The python3.9 -m venv
commands will create a new env-name
directory in the current working directory path. Inside, it will contain a few sub-directories:
bin/
: This is where the new Python executable and scripts/executables provided by other packages are...