# Virtual Environment

> A folder for one project. It holds the Python code that project needs.

**Field:** Software Development  
**Category:** Editors & Tools  
**Also known as:** venv, Python Virtual Environment, virtualenv, .venv

## Think of it like

It is like giving each child their own toy box. One child's mess never ends up in another's box.

## Definition

A virtual environment is a folder that holds the Python packages for one project. When it is on, what you install goes into that folder only. So two projects can use two versions of the same package, and both still work. You make one with python3 -m venv .venv, then turn it on before you install anything.

## Example

Emma's old project needs an old version of a package, and her new one needs the latest. Each gets its own .venv, and both work.

## Example code

```console
$ python3 -m venv .venv
$ source .venv/bin/activate
(.venv) $ pip install requests
```

Make the folder, turn it on, then install. The prompt shows which one is on.

## Why it matters

Without one, all your projects share the same packages. Then an update for one project can break another.

## Common mistake

Forgetting to turn it on, so pip installs into the main Python instead. Look for (.venv) at the start of the prompt.

## Three principles

- **One per project.** Each project gets its own folder.
- **Turn it on first.** Then installs go into that folder.
- **Throw it away freely.** Do not commit it; rebuild it any time.

## Related terms

- [Python](https://learn.benibix.com/term/development/python)
- [pip](https://learn.benibix.com/term/development/pip)
- [Dependency](https://learn.benibix.com/term/development/dependency)
- [Version Manager](https://learn.benibix.com/term/development/version-manager)
- [Package Manager](https://learn.benibix.com/term/development/package-manager)
- [uv](https://learn.benibix.com/term/development/uv)

## Told apart from

- [Virtual Environment vs Version Manager](https://learn.benibix.com/compare/virtual-environment-vs-version-manager): People think a virtual environment picks the Python version, and it does not. It keeps the packages of one project apart from the rest. A version manager picks which version of the language runs. Many projects use both: one for Python itself, one for its packages.

## Taught in

- [Virtual Environments and uv](https://learn.benibix.com/learn/development-tools/virtual-environments-and-uv): Coding Tools, 11/13

![Two project folders side by side on one computer. Project A has its own box marked .venv holding requests 2.31, and uses Python 3.12. Project B has its own box marked .venv holding requests 2.20, and uses Python 3.10. A version manager sits above both and switches the language version as you move between them. A note says each project keeps its own packages, so one cannot break the other.](https://learn.benibix.com/diagrams/dev-environments.svg)

---

Source: https://learn.benibix.com/term/development/virtual-environment
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
