Virtual environment
An isolated Python environment with its own installed packages, separate from the system Python.
A virtual environment is a private folder holding its own Python and its own installed packages. Creating one per project keeps each project's dependencies separate, so upgrading a package for one project can't break another.
Create one with python -m venv .venv, then activate it before installing anything with pip. Your shell prompt usually changes to show it's active.
python -m venv .venv # create it
source .venv/bin/activate # activate (Windows: .venv\Scripts\activate)
pip install flask # installs only inside this environment
Where this shows up in real Python
A virtual environment keeps each project’s packages separate, so upgrading one project can’t break another.
Commonly used Virtual environment tools
python -m venv .venv— create one in the project foldersource .venv/bin/activate— activate it (macOS/Linux)deactivate— step back outwhich python— confirm which Python is active
Official documentation: Python Library Reference: venv