Python venv Cheat Sheet/Create a .venv environment

Create a conventional project-local virtual environment.

Section: Create environments

Create a .venv environment

bash
bash
python -m venv .venv
Explanation

Creates a virtual environment in `.venv`. The Python docs recommend `venv` for isolated project environments, and `.venv` is a common convention. On Python, `venv` creates an isolated environment based on the interpreter you invoke.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Create environments
Create with python3
Use python3 explicitly on systems where python points elsewhere.
OpenIn sheetbashsame section
Upgrade an existing environment after Python upgrade
Upgrade the environment after the base interpreter changed.
OpenIn sheetbashsame section
Customize the shell prompt name
Set the prompt label shown when the environment is active.
OpenIn sheetbashsame section
Create with Windows py launcher
Create an environment using the Windows Python launcher.
OpenIn sheetpowershellsame section
Create with a specific Python version
Use a specific interpreter to choose the base Python version.
OpenIn sheetbashsame section
Create in a custom directory
Create a venv anywhere, not just in the project root.
OpenIn sheetbashsame section