All cheatsheetsPython Development

pip

pip 24+

Quick reference for the pip package installer CLI: install / uninstall / inspect packages, virtual environments, requirements files, configuration, and index management — with common options and practical examples.

37 commands

Help

pip --version

Print the pip version and the Python interpreter it points to.

pip --version
pip --help

List every pip subcommand.

pip --help
pip <subcommand> --help

Show all flags for one pip subcommand.

pip install --help | head -60

Self

python -m pip --version

Run pip as a Python module — preferred over `pip` directly on systems with multiple Python interpreters.

python -m pip --version
python -m pip install --upgrade pip

Upgrade pip to the latest version. Combine with `python -m ensurepip` to bootstrap pip into a venv that lacks it.

python -m pip install --upgrade pip
python -m ensurepip --upgrade

Bootstrap pip into a virtualenv that doesn't include it (PEP 453).

--upgrade; --default-pip

python -m ensurepip --upgrade

Install

pip install <pkg>

Install the latest version of `<pkg>` from the default index (PyPI).

<pkg>; -r <req.txt>; -e <path>; -U; --upgrade-strategy only-if-needed|eager; --force-reinstall; --no-deps; --pre include pre-releases; --dry-run; --quiet

pip install requests
pip install '<pkg>>=<ver>'

Install with a version specifier (PEP 440). Use `>=`, `==`, `<`, `~=`, `!=`, `===`.

pip install 'django>=4.2,<5'
pip install -r requirements.txt

Install every package listed in a requirements file (one specifier per line, `# comments` allowed).

-r <file>; -c <constraints>; --no-deps; --require-hashes

pip install -r requirements.txt
pip install -e <path>

Install a project in editable / development mode — your `src/` is symlinked into site-packages, edits are picked up live.

-e .; -e .[dev]; --no-deps

pip install -e .
pip install '.[dev]'

Install the current project with the optional extras declared in `pyproject.toml`.

pip install '.[dev,docs]'
pip install git+https://github.com/<user>/<repo>.git

Install directly from a Git repository (any ref: branch, tag, commit).

git+https://...; git+ssh://...; @branch; @tag; @commit

pip install 'git+https://github.com/requests/requests.git@main'
pip install <pkg> --index-url <url>

Install from an alternate index — corporate PyPI mirror, JFrog Artifactory, AWS CodeArtifact, etc.

pip install <pkg> --index-url https://pypi.org/simple
pip install <pkg> --extra-index-url <url>

Search an additional index alongside the default. Use `--no-index` to forbid remote fetches entirely.

pip install <pkg> --extra-index-url https://my-mirror/simple
pip install --user <pkg>

Install into the user's site-packages (`~/.local/`) instead of the system Python.

--user; --target <dir>

pip install --user pipx
pip install --dry-run <pkg>

Print what pip would install without actually installing — useful for CI previews.

--dry-run; --quiet; --report <file>

pip install --dry-run -r requirements.txt

Inspect

pip list

List installed packages (Name / Version / Location columns).

--format columns|freeze|json; --outdated; --uptodate; --user; --local; --pre; --not-required; --exclude; --include-editable

pip list --format=freeze > freeze.txt
pip list --outdated

List installed packages that have a newer version available.

--outdated; --format columns|freeze|json

pip list --outdated --format=columns
pip show <pkg>

Show metadata for a single installed package: version, location, requires, required-by, summary.

-f show every file; --files same; <pkg>...

pip show -f requests
pip check

Verify installed packages have compatible dependencies — surfaces broken dep conflicts.

pip check
pip freeze

Output installed packages in `pkg==ver` format (sorted, no extras) — the canonical requirements.txt source.

--local; --user; --all; --exclude; --requirement <file>

pip freeze > requirements.lock

Uninstall

pip uninstall <pkg>

Uninstall a package. Pass `-y` to skip the confirmation prompt.

<pkg>...; -y; -r <file> uninstall every package listed; --dry-run

pip uninstall -y requests
pip uninstall -r requirements.txt -y

Uninstall every package listed in a requirements file.

pip uninstall -r requirements.txt -y

Index

pip download <pkg>

Download wheels / sdist into a directory without installing. Useful for air-gapped transfers.

-d <dir>; --no-deps; --no-binary :all:; --dest <dir>; --platform

pip download requests -d ./wheels
pip search <query>

Search PyPI for a package by name / summary (currently disabled by PyPI; use the web UI instead).

pip search 'fastapi'
pip wheel <pkg>

Build wheels for a project and its dependencies into an output directory.

-w <dir>; --no-deps; --no-binary :all:; --no-build-isolation

pip wheel . -w ./wheels
pip cache dir

Print the directory pip uses to cache downloaded files.

pip cache dir
pip cache purge

Clear pip's download cache. Useful when fixing a corrupted wheel file.

purge; list; info; remove <pattern>; --no-autoremove

pip cache purge
pip config list

Print the active configuration (env vars + INI files at site / global / user scopes).

list; edit; get <name>; set <name> <value>; unset <name>; --global; --user; --site

pip config list
pip config set global.index-url <url>

Persist a setting into the active config file.

--global; --user; --site; --editor; <name> <value>

pip config set global.index-url https://my-mirror/simple

Inspection

pip inspect

Dump every dependency, file, and metadata record of every installed package as JSON (used by Dependabot etc.).

pip inspect > installed.json

Hash

pip install --require-hashes -r requirements.txt

Install with hash-pinned requirements — pip refuses anything whose hash doesn't match (reproducible, tamper-proof).

pip install --require-hashes -r requirements.txt
pip hash <file>

Compute the SHA-256 (default) hash of a file for use in `--require-hashes` requirements.

<file>; --algorithm sha256|sha384|sha512

pip hash ./mypkg-1.0-py3-none-any.whl

VCS

pip install git+ssh://[email protected]/<user>/<repo>@<ref>

Install over SSH (useful for private packages behind 2FA).

@<branch>; @<tag>; @<commit>

pip install git+ssh://[email protected]/me/[email protected]

Venv integration

python -m venv .venv

Create a virtual environment (Python's stdlib alternative to virtualenv). pip auto-installs into the venv once activated.

.venv; --system-site-packages; --prompt <name>; --without-pip; --upgrade-deps

python -m venv .venv && source .venv/bin/activate

Misc

pip debug --verbose

Show which pip version, supported tags (`cp311-cp311-manylinux_2_28_x86_64`), and Python versions pip can install for.

--verbose

pip debug --verbose | head -40
pip install --upgrade pip setuptools wheel

Upgrade the build toolchain inside the venv — needed when source distributions need a newer setuptools.

pip install --upgrade pip setuptools wheel

Related command cheatsheets

About pip

pip is the standard Python package manager — the recursive acronym "pip installs packages". It was originally created by Ian Bicking in 2008 and adopted into the Python standard library as the default installer in Python 2.7.9 / 3.4. pip installs Python packages from PyPI (the Python Package Index) and any compatible PEP 503 repository. The current stable line is pip 24+ (with pip 25.x removing legacy resolver warnings). pip supports wheels (.whl), source distributions (.tar.gz), VCS URLs (`git+https://...`), and local editable installs (`pip install -e .`). For most workflows uv / Poetry / Hatch now supersede pip for project management, but pip remains the universal fallback — almost every Python tool's documentation assumes `pip install <pkg>`. pip is MIT-licensed, distributed under the Python Packaging Authority (PyPA). pip never uploads your code; it only fetches from configured indexes.

Cheatsheet version 1.0.0