~$ man environnement-virtuel
What is a Python virtual environment (venv)?
definition
A virtual environment in Python is a self-contained directory tree that contains a Python installation and its own set of packages. It lets developers install libraries for one project without affecting the system Python or other projects.
The built-in venv module creates these isolated spaces. Each environment has its own pip and site-packages folder so different projects can safely use different versions of the same library.
Using a virtual environment is standard practice in Python development to avoid dependency hell and make projects reproducible across machines.
Think of a virtual environment like having separate lunchboxes for each kid in a family: one child can pack peanut-butter sandwiches while another packs only gluten-free snacks, and nothing spills between boxes.
key takeaways
- A virtual environment isolates project dependencies so one project cannot break another.
venvis included with Python 3.3 and later so no extra install is needed.- Always activate the environment before installing packages with pip.
- Store the list of installed packages in a requirements.txt file for easy recreation.
- Never commit the virtual environment folder itself to version control.
the 2026 job market
In 2026 Python remains the dominant language for data, web, and automation work; every job posting that lists Python also expects candidates to know how to manage dependencies with virtual environments, making this skill a basic requirement for junior and mid-level Python developer, data engineer, and automation roles.
frequently asked questions
How do I create a Python virtual environment?
Run python -m venv env in your project folder. This creates a new directory named env that holds an isolated Python installation.
How do I activate a virtual environment on Windows?
Use the command env\Scripts\activate in Command Prompt or PowerShell. Your prompt will show the environment name when it is active.
Should I use conda or venv for Python projects?
venv is lighter and built into Python, while conda adds package and environment management across languages. Most pure-Python projects start with venv.
What happens if I forget to activate my virtual environment?
pip will install packages into the global Python instead of the project folder, which can cause version conflicts with other work.
