What is a virtual environment?
A virtual environment is a private folder of Python packages for one project, so different projects never clash.
Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?
A virtual environment is an isolated set of installed Python packages that belongs to a single project. Picture a toolbox per job instead of one giant shared drawer: the plumbing job gets its wrenches, the painting job gets its brushes, and nothing gets mixed up. Each project can then use the exact library versions it was built with.
You create one with python -m venv .venv, activate it, and everything pip installs goes into that folder. Editors such as VS Code detect it automatically. Other languages solve the same problem differently: Node keeps packages in a local node_modules folder, Ruby uses Bundler, and containers can isolate an entire application.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install requests
See also: What is a dependency? and What is a package manager?
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0001 Virtual environments with venv A virtual environment is a private folder of Python packages for one project, so projects never fight over versions. Create one with… Beginner · Explains an idea · Any system Article Environments & packages 15 Oct 2026
- 0007 Fix: ModuleNotFoundError: No module named ‘…’ Python cannot find a module you import. Usually the package was installed into a different interpreter or virtual environment than the one… Beginner · Fixes an error · Any system Article Common errors · Environments & packages 15 Oct 2026
- 0011 Bootstrap a new Python project with a venv A Bash script that creates a project folder with a virtual environment, .gitignore, requirements.txt and a starter main.py, then runs it to… Intermediate · Step by step · Linux, macOS Script Environments & packages 15 Oct 2026
- 0261 Build a Python command-line to-do app: from empty folder to installable command Create a small to-do tool in Python with argparse and JSON storage, test it with pytest and package it with pyproject.toml so… Beginner · Guided project · Any system Article Environments & packages · Files & automation · Testing 15 Oct 2026
- 0282 What is a dependency? A dependency is another piece of software your program needs to work, such as a library it imports. Beginner · Explains an idea · Any system Article Environments & packages 15 Oct 2026
- 0387 Install Python on Linux, macOS and Windows Install a current Python 3 with pip and venv on each desktop OS, check the version, and avoid the classic traps: python… Beginner · Step by step · Linux, macOS, Windows Article Environments & packages · Installing languages & tools 15 Oct 2026
Repos in the wild
- uv: Python package and project manager astral-sh/uv uv is a very fast Python package and project manager written in Rust. It replaces pip, venv and related tools, manages lock files and can install Python itself. GitHub
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Dominik +814 chars