← Back to Command Library

Python

Python Virtual Environment Quick Start

Create venv, activate, install packages, and lock dependencies.

Reliable Python dependency isolation workflow.

Version

Python 3.10+

Tags

python,venv,pip

Views

5

Problem

Global package conflicts can break project behavior.

Solution Summary

Use virtual environments and requirements file for reproducible setup.

Step 1

python -m venv .venv
Note: Create a virtual environment.

Step 2

.\.venv\Scripts\activate
Note: Windows activation. Linux/macOS: source .venv/bin/activate

Step 3

python -m pip install --upgrade pip
Note: Upgrade pip.

Step 4

pip install flask requests
Note: Install sample dependencies.

Step 5

pip freeze > requirements.txt
Note: Generate dependency lock file.