Python Venv

1. Check installed python3

$ python3 --version
Python 3.12.3

In case python3 is not found install it

apt install python3

2. Install -venv package

For python3 you need to install additional package for creating virtual environment:

apt install python3.12-venv

3. Using venv

Creating

To create the virtual environment:

python3 -m venv .venv

Where .venv is the name of the virtual environment - it can be anything you want, just keep it consistent with later commands.

Activating

To start the virtual environment source the activate script

source .venv/bin/activate

You should see name of your virtual environment added to the shell prompt in e.g.

(.venv) root@5763a8789136: 

Deactivating

To deactivate the environment just type deactivate in the console, the prefix from prompt should vanish.

4. Installing packages

The virtual environment separates your packages from the system ones you can use now packages using pip install command.

Date: 2025-12-05