Sitemap
Lumenyx

Lumenyx

Set up a Python Virtual Environment on Debian/Ubuntu

Feb 21, 2026

A Python virtual environment is used when project-specific dependencies need to be installed that may cause conflicts with other dependencies on the system.

https://dev.to/towernter/setting-up-a-python-virtual-environment-on-windows-1l4p

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 python3

Install the package needed to create Python virtual environments:

sudo apt install python3-venv -y

Create the virtual environment:

python3 -m venv [virtual-environment-name]
Press enter or click to view image in full size

This creates the virtual environment within your current directory. However you need another command to enter it:

source [virtual-environment-name]/bin/activate

Now 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:

Press enter or click to view image in full size
Press enter or click to view image in full size

Exit the virtual environment:

deactivate

--

--