pip, Virtual Environments, and Interpreters Cheat Sheet

Use pip correctly across Python versions, venvs, pyenv-style setups, CI, and system interpreters.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Prefer python -m pip
Use pip with Python 3 explicitly
python3 -m pip install requests

# Install a package with a specific interpreter family.

Use pip with a specific Python version
python3.11 -m pip install requests

# Install into Python 3.11 specifically.

Confirm interpreter path
python -c "import sys; print(sys.executable)"

# Print the interpreter path in use.

## venv Workflows
Create venv and install packages
python -m venv .venv && source .venv/bin/activate && python -m pip install --upgrade pip

# Typical Unix-like local development flow.

Install requirements into an active venv
python -m pip install -r requirements.txt

# Install project dependencies after activation.

Install to user site packages
python -m pip install --user httpie

# Install packages into the user site directory.

Install despite externally managed environment
python -m pip install --break-system-packages requests

# Override system package management protections when necessary.

## CI and Automation
Upgrade pip, setuptools, and wheel
python -m pip install --upgrade pip setuptools wheel

# Bootstrap common packaging tools in CI.

Run without prompts
python -m pip install --no-input -r requirements.txt

# Disable interactive prompts for automation.

Disable version check
PIP_DISABLE_PIP_VERSION_CHECK=1 python -m pip install -r requirements.txt

# Skip pip’s self-update version check.

Recommended next

No recommendations yet.