Koskamo

Virtual environments with venv

Document v1 · published by Koskamo editorial · updated 2026-10-04

Original source

Python applications often need specific library versions that conflict with one another, and a virtual environment solves this: a self-contained directory tree containing a Python installation for a particular version plus additional packages. The venv module creates and manages virtual environments and installs the Python version from which the command was run. Run python -m venv with a directory path to create one; .venv is a common location, hidden in the shell and not clashing with .env environment-variable files. Activate with Scripts\activate on Windows or source bin/activate on Unix or macOS (activate.csh and activate.fish exist for the csh and fish shells); activation changes the shell prompt and makes python resolve to that installation, but does not alter PYTHONPATH, and the tutorial's best practice is to unset it. Manage packages with pip (install, uninstall, freeze), pin a version with ==, and leave the environment with deactivate. Scope: Python 3. Reviewed October 4, 2026.

Source and provenance

Original source
docs.python.org
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.