pip Install and Dependencies Cheat Sheet

Dependency installation patterns with pip, including constraints, editable installs, extras, local paths, VCS installs, and resolver control.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Requirements Files
Install from requirements file
python -m pip install -r requirements.txt

# Install dependencies listed in a requirements file.

Write frozen versions to requirements.txt
python -m pip freeze > requirements.txt

# Generate a pinned requirements file from the active environment.

Install with constraints
python -m pip install -r requirements.txt -c constraints.txt

# Use a constraints file while installing dependencies.

Install multiple requirements files
python -m pip install -r requirements.txt -r requirements-dev.txt

# Combine base and environment-specific requirement lists.

## Extras, Editable, and Local Installs
Install current project in editable mode
python -m pip install -e .

# Install a local project with editable imports.

Install editable project with extras
python -m pip install -e ".[dev]"

# Install a project in editable mode with optional dependency groups.

Install package extras
python -m pip install "requests[socks]"

# Install optional extras defined by a package.

Install from local path
python -m pip install ./my-package

# Install a package from a local directory.

Install all wheels from a directory
python -m pip install ./dist/*.whl

# Install wheel artifacts stored in a local folder.

## VCS and Direct URLs
Install from a Git repository over HTTPS
python -m pip install git+https://github.com/pallets/click.git

# Install a package directly from a Git repo.

Install from a specific Git ref
python -m pip install git+https://github.com/pallets/click.git@8.1.7

# Pin a VCS install to a tag, branch, or commit.

Install from a direct archive URL
python -m pip install https://files.pythonhosted.org/packages/.../package.whl

# Install from a remote source archive or wheel URL.

## Resolver and Platform Controls
Use eager upgrade strategy
python -m pip install --upgrade --upgrade-strategy eager fastapi

# Upgrade transitive dependencies more aggressively.

Require wheels for a package
python -m pip install --only-binary pandas pandas

# Only accept binary wheels for a named package.

Resolve for a target platform and Python
python -m pip download --platform manylinux2014_x86_64 --python-version 311 --only-binary=:all: numpy

# Download distributions for another platform or interpreter version.

Install into a target directory
python -m pip install --target ./vendor requests

# Install packages into a custom filesystem path.

Recommended next

No recommendations yet.