virtual environment
An isolated folder on your computer where a Python program runs with its own add-ons without interfering with other programs.
In plain terms
Imagine preparing a separate tray for every recipe in your kitchen: one holds flour and sugar for cookies, another holds paprika and onions for stew. Nothing gets mixed up, and if you discard one tray, the other remains untouched. A virtual environment does exactly this for programs.
Programs written in Python almost always rely on add-ons written by others, known as packages. The problem is that one program needs an old version of a package while another needs the new one, and the two cannot coexist in the same place. A virtual environment gives each project its own separate shelf for its packages.
In the AI world, this is everyday: almost every open-source AI tool's installation guide starts with creating a virtual environment. Coding agents also regularly create such environments before installing anything, so as not to mess up the rest of your machine.
How it works
- With one command, you create a new folder next to your project (often called .venv); this contains a copy of the Python interpreter or a reference to it, and an empty space for packages.
- You 'activate' the environment: from then on, the command-line window looks for Python and packages in this folder, not in the machine's common location.
- What you install afterward goes only into this folder, so your other projects and the system's own Python remain unchanged.
- You save the list of installed packages in a small text file (such as requirements.txt), from which anyone else can rebuild the same environment on their own machine.
- If it is no longer needed or something breaks, simply delete the folder and create a new one with a clean slate.
An everyday example
You want to try an AI tool downloaded from GitHub, and the first line of the guide is: 'python -m venv .venv'. This command creates a small separate box into which the tool's dependencies are placed. If you later get tired of it, deleting the folder makes these dependencies disappear from your machine. Files downloaded elsewhere, such as large AI models and the installer cache, may remain.
Who is affected
A common misconception
Limits and risks
- Not a security boundary: a malicious package can access your data even from a virtual environment.
- It separates only Python packages; it does not separate other operating system components, such as the graphics card driver.
- The folder is not portable: if you move it or copy it to another machine, it typically breaks, so it is better to rebuild it from the package list.
- In AI projects, a single environment can take up several gigabytes, and if you have many projects, this can quickly fill the disk.
Similar, but not the same
- container – A container packages the program's entire runtime environment and isolates it from the system, whereas a virtual environment only separates Python packages.
- virtual machine – A virtual machine emulates a complete, independent computer with its own operating system, while a virtual environment is just a folder within your existing system.
- sandbox – The sandbox's purpose is restriction, so that the program cannot access just anything, while the virtual environment only keeps order among packages.
Related concepts
development environment, isolation, dependency management
conda environment
Package manager, dependency, requirements.txt, container, sandbox, Python
A brief history
The idea was popularized by a tool called virtualenv, released by Ian Bicking in 2007. The solution became an integrated part of the language in 2012, with Python version 3.3, under the name venv.
Where things stand
At the end of 2026, this is the default practice in Python development, and most guides take it for granted. Newer, faster tools (such as uv) and coding agents increasingly create it automatically, so you often do not even notice.
Also known as
virtual environment · virtual environment · venv · .venv · virtualenv · Python virtual environment · Python environment · Python virtual environment
Sources
This entry was machine-edited and has undergone machine expert review; the “In the news” section updates automatically from Agent Age stories.