Virtual Environment in Python — a practical guide to Python virtualenv venv with clear examples you can reuse in real projects.
Python Tutorial Series (36/95). Prefer one article? Read the complete Python tutorial.
Short description
Always create a virtual environment per project. Activate it before installing packages.
Steps
- Create
.venvwithpython -m venv. - Activate the environment.
- Install packages inside it only.
Create and activate venv
python -m venv .venv
# Windows PowerShell:
.venvScriptsActivate.ps1
# macOS/Linux:
# source .venv/bin/activate
pip install flask