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
Python
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)