A virtual environment (venv) is an isolated Python environment created for a specific project.
It allows you to manage project-specific dependencies without interfering with other projects or the original Python installation.

Using virtual environments is important because:

  • It prevents package version conflicts between projects
  • Makes projects more portable and reproducible
  • Keeps your system Python installation clean
  • Allows testing with different Python versions


Creation :
Python
python -m venv env
Run this inside your project folder .
Here, env is the environment name

This creates Folders :
bash
env/ ├─ Scripts/ (Windows) ├─ bin/ (Linux/Mac) ├─ Lib/ └─ pyvenv.cfg 

Activate Virtual Environments :
Windows :
Bash/Shell
env\Scripts\activate 

Linux / Mac :
Bash/Shell
source env/bin/activate 

Install Packages inside env :
Bash/Shell
pip install django pip install requests 

Deactivate Virtual Environment :
Bash/Shell
deactivate 

Delete Virtual Environments :
Bash/Shell

delete env/ (Windows) rm -rf env/ (Linux / Mac)