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

Install dependencies listed in a requirements file.

bashANYrequirementsinstall
bash
python -m pip install -r requirements.txt
Notes

Common project bootstrap command for development or deployment.

Write frozen versions to requirements.txt

Generate a pinned requirements file from the active environment.

bashANYfreezerequirementspinning
bash
python -m pip freeze > requirements.txt
Notes

Produces exact installed versions for reproducible installs.

Install with constraints

Use a constraints file while installing dependencies.

bashANYconstraintsrequirementsresolver
bash
python -m pip install -r requirements.txt -c constraints.txt
Notes

Constraints restrict versions without necessarily declaring top-level requirements.

Install multiple requirements files

Combine base and environment-specific requirement lists.

bashANYrequirementsdevelopmentinstall
bash
python -m pip install -r requirements.txt -r requirements-dev.txt
Notes

Useful when splitting runtime and development dependencies.

Extras, Editable, and Local Installs

Install current project in editable mode

Install a local project with editable imports.

bashANYeditablelocaldevelopment
bash
python -m pip install -e .
Notes

Common for local package development. Changes in source are reflected without reinstalling.

Install editable project with extras

Install a project in editable mode with optional dependency groups.

bashANYeditableextrasdevelopment
bash
python -m pip install -e ".[dev]"
Notes

Great for local development setups that need test or lint dependencies.

Install package extras

Install optional extras defined by a package.

bashANYextrasoptional-dependencies
bash
python -m pip install "requests[socks]"
Notes

Extras activate optional dependency sets defined by the package.

Install from local path

Install a package from a local directory.

bashANYlocal-pathinstall
bash
python -m pip install ./my-package
Notes

Useful for local monorepo or package development workflows.

Install all wheels from a directory

Install wheel artifacts stored in a local folder.

bashANYwheellocal-file
bash
python -m pip install ./dist/*.whl
Notes

Helpful when testing freshly built artifacts locally.

VCS and Direct URLs

Install from a Git repository over HTTPS

Install a package directly from a Git repo.

bashANYgitvcsdirect-url
bash
python -m pip install git+https://github.com/pallets/click.git
Notes

Good for unreleased code or internal repos exposed via Git.

Install from a specific Git ref

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

bashANYgitversionsvcs
bash
python -m pip install git+https://github.com/pallets/click.git@8.1.7
Notes

Pinning a ref improves reproducibility versus floating branches.

Install from a direct archive URL

Install from a remote source archive or wheel URL.

bashANYurlarchiveinstall
bash
python -m pip install https://files.pythonhosted.org/packages/.../package.whl
Notes

Useful for direct artifacts and private file endpoints.

Resolver and Platform Controls

Use eager upgrade strategy

Upgrade transitive dependencies more aggressively.

bashANYupgraderesolver
bash
python -m pip install --upgrade --upgrade-strategy eager fastapi
Notes

Can help bring an environment fully up to date, but may cause larger dependency changes.

Require wheels for a package

Only accept binary wheels for a named package.

bashANYbinarywheelsresolver
bash
python -m pip install --only-binary pandas pandas
Notes

Useful when builds from source are slow or unavailable in CI.

Resolve for a target platform and Python

Download distributions for another platform or interpreter version.

bashANYplatformpython-versiondownload
bash
python -m pip download --platform manylinux2014_x86_64 --python-version 311 --only-binary=:all: numpy
Notes

Often used when building deploy artifacts for another runtime environment.

Install into a target directory

Install packages into a custom filesystem path.

bashANYtargetvendorinstall
bash
python -m pip install --target ./vendor requests
Notes

Useful for zip apps, lambdas, or vendored packaging layouts.

Recommended next

No recommendations yet.