pip Cheat Sheet
Python package management — install, freeze, virtualenvs, and the resolution options that keep environments sane.
Build & Package4 sections · 21 commands
⌘K
Installing
8pip install PACKAGEInstall a package
pip install -r requirements.txtInstall from a requirements file
pip install 'PACKAGE>=1.0,<2.0'Range constraint
pip install -e ./local_pkgEditable local package
pip install --upgrade PACKAGEUpgrade a package
pip uninstall PACKAGERemove a package
pip listInstalled packages (paged)
pip show PACKAGEPackage metadata and location
Freeze & Requirements
4pip freeze > requirements.txtPin the whole environment
pip freeze | diff - requirements.txtDrift between pins and reality
pip checkVerify dependencies are satisfied
pip install 'PACKAGE==1.2.3'Exact pin
Virtual Environments
4python -m venv .venvCreate a virtualenv
source .venv/bin/activateActivate it (Unix)
.venv\Scripts\activateActivate on Windows
which pythonConfirm you're in the venv
Config & Index
5pip config listEffective pip config
pip install PACKAGE -i https://pypi.org/simpleCustom index URL
pip cache infoCache size and location
pip install --no-cache-dir PACKAGEBypass cache
python -m pip install --upgrade pipUpgrade pip itself