Python: Creating a virtual environment
virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip.
Note: If you are using Python 3.3 or newer, the venv module is the preferred way to create and manage virtual environments. venv is included in the Python standard library and requires no additional installation.
Installing virtualenv
python3 -m pip install --user virtualenvCreating a virtual environment
python3 -m venv envActivating a virtual environment
source env/bin/activateInstall packages
pip install -r requirements.txtFreeze requirements
pip freeze > requirements.txtLeaving the virtual environment
deactivateReference: