Python venv Cheat Sheet/Recreate from requirements in one line

Delete, recreate, and reinstall dependencies.

Section: Reset and rebuild

Recreate from requirements in one line

bash
bash
rm -rf .venv && python -m venv .venv && source .venv/bin/activate && python -m pip install -U pip setuptools wheel && python -m pip install -r requirements.txt
Explanation

A compact rebuild flow for local development on POSIX shells.

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 Reset and rebuild
Delete a venv on Linux/macOS
Remove the environment directory completely.
OpenIn sheetbashsame section
Delete a venv on PowerShell
Remove the environment directory recursively.
OpenIn sheetpowershellsame section
Typical Makefile rebuild target
Automate the rebuild workflow in a Makefile target.
OpenIn sheetmakefilesame section
Reinstall exactly from requirements
Force reinstall to match a requirements file closely.
OpenIn sheetbashsame section
Create a .venv environment
Create a conventional project-local virtual environment.
OpenIn sheetbash1 tag match
Create with python3
Use python3 explicitly on systems where python points elsewhere.
OpenIn sheetbash1 tag match