SudoHopeX 'Krishna Dwivedi' SudoHopeX 🥷🚩

A Ray of Hope in the circuitry, Igniting curiosity.

( Ethical Hacker )

Running & Configuring Python venv3 in Linux

calendar Jul 24, 2025 clock 2-3 min read tag Article

python venv structure

What is Python venv ??

A Python virtual environment (venv) is a tool that helps you create a separate space for each of your Python projects. This space includes its own version of Python and its own set of packages (libraries).

A virtual environment (venv) is simply a directory with a specific file structure, containing a Python interpreter and directories for installed packages.

Using venv avoids conflicts between projects, especially when different projects need different versions of the same library. It's like having a clean, self-contained workspace for every project.

The venv module is built into Python, so you don't need to install anything extra to use it.

When we activate a venv, it modifies the environment variables to prioritize the venv's directories, ensuring that the correct Python interpreter and packages are used, instead of the global ones.


Directories ( folders ) within a Venv 👇

python venv3 containner look 1

Real-Life Analogy

Imagine you're a chef working in a large Indian wedding catering service. You have to cook for multiple weddings happening on the same day:

In the same way, Python virtual environments make sure each project has exactly what it needs, without interfering with others.

Install Python venv3

Install py venv using apt:

sudo apt update && sudo apt install python3-venv

or using pyenv:

curl https://pyenv.run | bash

Create a Virtual Environment

Navigate to your desired directory and run:

python3 -m venv env_name
( env_name is the name of your virtual environment directory )

Activate the Virtual Environment

source env_name/bin/activate (Bash shell)

For other shells:

source env_name/bin/activate.fish (fish shell)
source env_name/bin/activate.csh (csh shell)

Deactivate the Virtual Environment

Just by running the folllowing command inside the venv:

deactivate

Delete the Virtual Environment

We can delete the Venv by command:

rm -rf env_name

Usage Example

Further articles to Explore
30 Days to Master XSS with Games, Challenges and Labs + SQL Injection Research Paper: A deep dive into SQLi +
Go to top