Python 3.3+ comes with the venv
library, providing support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories.
To create an isolated virtual environment for Python type python -m venv <name_of_virtual_env>
python -m venv local_env
This will create a local_env/
directory, including your Python environment. Any Python libraries you install while your virtual environment is active will go into the local_env/lib/python3.8/site-packages
directory.
After creating the virtual environment, next step is to activate your virtual environment, which can be done as follows
source local_env/bin/activate
The shell prompt will include the name of the active virtual environment enclosed in parentheses, as follows:
(local_env) ➜ projects
To de-activate virtual environment type deactivate
command and press Enter
key.