Set up a Python Virtual Environment on Debian/Ubuntu
A Python virtual environment is used when project-specific dependencies need to be installed that may cause conflicts with other dependencies on the system.
You simply use the virtual environment, and the dependencies within are isolated from the rest of the system, therefore causing no conflicts.
Get Lumenyx’s stories in your inbox
Join Medium for free to get updates from this writer.
Ensure python3 is installed:
sudo apt install python3Install the package needed to create Python virtual environments:
sudo apt install python3-venv -yCreate the virtual environment:
python3 -m venv [virtual-environment-name]This creates the virtual environment within your current directory. However you need another command to enter it:
source [virtual-environment-name]/bin/activateNow binaries installed with PIP (no sudo) are saved in the [virtual-environment-name]/bin folder, and the libraries are stored in the[virtual-environment-name]/lib folder:
Exit the virtual environment:
deactivate








