Python Virtual Environment
A virtual environment is an isolated workspace that allows you to install Python packages separately for different projects.
๐งช Virtual environments prevent package version conflicts.
Why Use a Virtual Environment?
- Different projects need different package versions
- Keeps global Python installation clean
- Easy dependency management
Create a Virtual Environment
python -m venv myenv
Activate Virtual Environment
Windows:
myenv\Scripts\activate
Linux / macOS:
source myenv/bin/activate
Deactivate Virtual Environment
deactivate
โ Always activate the environment before installing packages.