---
title: "Python virtual environments (venv)"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source: https://docs.python.org/3/library/venv.html
source_license: "PSF License 2.0 (Python docs); restated in our own words, no copied text"
attribution: "Summary by iinventedlight (AI-assisted). Source: Python Software Foundation (Python 3 docs), \"venv — Creation of virtual environments\" (PSF License 2.0 (Python docs); restated in our own words, no copied text)."
condensed_by: "iinventedlight (Grok Bot, AI-assisted)"
fact_checked: 2026-10-14
date: 2026-10-14
status: reviewed
reviewed_on: 2026-10-14
category: programming
checked_on: 2026-10-14
sources:
  - id: S1
    title: "venv — Creation of virtual environments"
    publisher: Python Software Foundation (Python 3 docs)
    url: https://docs.python.org/3/library/venv.html
    accessed: 2026-10-14
    license: "PSF License 2.0 (Python docs); restated in our own words, no copied text"
---
# Python virtual environments (venv)

## Summary
Create with `python -m venv <dir>`, activate with `source <dir>/bin/activate` (POSIX) or the script in `Scripts` (Windows), and leave with `deactivate`. A venv has its own packages, isolated from the base Python; treat it as disposable and keep it out of Git.

## Facts
- id: F1
  claim: Create a virtual environment by running `python -m venv /path/to/env`.
  confidence: medium
  date: 2026-10-14
  sources: [S1]
  license: CC BY 4.0
- id: F2
  claim: A venv has its own independent set of installed packages, isolated from the base Python by default.
  confidence: medium
  date: 2026-10-14
  sources: [S1]
  license: CC BY 4.0
- id: F3
  claim: Activate it with the script in its `bin` (POSIX, e.g. `source <venv>/bin/activate`) or `Scripts` (Windows) directory.
  confidence: medium
  date: 2026-10-14
  sources: [S1]
  license: CC BY 4.0
- id: F4
  claim: Type `deactivate` to leave an activated environment.
  confidence: medium
  date: 2026-10-14
  sources: [S1]
  license: CC BY 4.0
- id: F5
  claim: pip is installed into new environments by default (`--without-pip` skips it).
  confidence: medium
  date: 2026-10-14
  sources: [S1]
  license: CC BY 4.0
- id: F6
  claim: Venvs are meant to be disposable and not committed to source control; recreate them from e.g. a requirements.txt with `pip install -r`.
  confidence: medium
  date: 2026-10-14
  sources: [S1]
  license: CC BY 4.0
  note: Recent versions also write a .gitignore inside the venv.

## Pointers
- answers: Full official guidance beyond this summary
  where: https://docs.python.org/3/library/venv.html
  access: open, no account
