A concise, no-fluff guide to Python virtual environments covering creation, activation, deactivation, and deletion using the built-in venv module. Also covers bonus scenarios: running venv commands from shell scripts, using the venv Python binary directly without activating, shebang line patterns for scripts, and a mention of the third-party uv tool as an alternative.

6m read timeFrom beej.us
Post cover image
Table of contents
What is a Virtual Environment?Creating the Virtual EnvironmentActivating ItDo Things In ItDeactivate ItDeleting ItBonus: Running from a Shell ScriptBonus II: Running Python Scripts DirectlyBonus III: Using a Third-Party ToolComments

Sort: