pip Cheat Sheet

Python package management — install, freeze, virtualenvs, and the resolution options that keep environments sane.

Build & Package4 sections · 21 commands
⌘K

Installing

8
pip install PACKAGE

Install a package

pip install -r requirements.txt

Install from a requirements file

pip install 'PACKAGE>=1.0,<2.0'

Range constraint

pip install -e ./local_pkg

Editable local package

pip install --upgrade PACKAGE

Upgrade a package

pip uninstall PACKAGE

Remove a package

pip list

Installed packages (paged)

pip show PACKAGE

Package metadata and location

Freeze & Requirements

4
pip freeze > requirements.txt

Pin the whole environment

pip freeze | diff - requirements.txt

Drift between pins and reality

pip check

Verify dependencies are satisfied

pip install 'PACKAGE==1.2.3'

Exact pin

Virtual Environments

4
python -m venv .venv

Create a virtualenv

source .venv/bin/activate

Activate it (Unix)

.venv\Scripts\activate

Activate on Windows

which python

Confirm you're in the venv

Config & Index

5
pip config list

Effective pip config

pip install PACKAGE -i https://pypi.org/simple

Custom index URL

pip cache info

Cache size and location

pip install --no-cache-dir PACKAGE

Bypass cache

python -m pip install --upgrade pip

Upgrade pip itself