Install
apt install python3-venv
To setup a Python virtual environment
python3 -m venv /opt/project/
Activate the new environment
source /opt/project/bin/activate
Show installed packages. You'll notice the venv only has a few packages installed.
pip list
Generate a requirements.txt file with project dependencies
pip freeze > requirements.txt
To install dependencies from text file
pip install -r requirements.txt
To deactivate/exit the Python venv
deactivate