Skip to main content

pip Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for pip commands covering package installation, version constraints, requirements files, upgrades, virtual environments, and configuration.

pip is the package installer for Python. This cheatsheet covers common pip commands for installing and removing packages, pinning versions, working with requirements files, inspecting installed packages, managing virtual environments, and configuring pip.

Install Packages

Add packages from PyPI and other sources.

CommandDescription
pip install packageInstall the latest version
pip install pkg1 pkg2Install several packages
pip install --user packageInstall into the user site
pip install -e .Install local project in editable mode
pip install 'package[extra]'Install with optional extras
pip install ./dist/pkg.whlInstall from a wheel file
python -m pip install packageInstall through the python launcher

Versions and Sources

Pin versions and install from other indexes.

CommandDescription
pip install package==1.2.3Install an exact version
pip install 'package>=1.0,<2.0'Install within a version range
pip install --upgrade packageUpgrade to the latest version
pip install --pre packageAllow pre-release versions
pip install 'git+https://host/repo.git'Install from a Git repository
pip install -i https://mirror/simple packageUse an alternate index URL
pip index versions packageList available versions

Requirements Files

Record and reproduce a project environment.

CommandDescription
pip install -r requirements.txtInstall from a requirements file
pip freezePrint installed packages with versions
pip freeze > requirements.txtWrite current packages to a file
pip download -r requirements.txt -d ./pkgsDownload packages without installing
pip install --no-deps -r requirements.txtInstall without dependencies
pip uninstall -r requirements.txtRemove packages listed in a file

Remove Packages

Uninstall packages and verify the tree.

CommandDescription
pip uninstall packageRemove a package
pip uninstall -y packageRemove without confirmation
pip uninstall pkg1 pkg2Remove several packages
pip checkVerify installed dependencies

Inspect Packages

List installed packages and read metadata.

CommandDescription
pip listList installed packages
pip list --outdatedShow packages with newer versions
pip list --not-requiredList packages no other package needs
pip show packageShow package details
pip show -f packageList files installed by a package
pip --versionShow the pip and Python version

Virtual Environments

Isolate project dependencies with venv.

CommandDescription
python -m venv myenvCreate a virtual environment
source myenv/bin/activateActivate the environment (Linux/macOS)
deactivateLeave the active environment
pip install --upgrade pipUpgrade pip inside the environment
pip install --break-system-packages packageOverride PEP 668 (use sparingly)

Configuration and Cache

Adjust pip settings and manage the cache.

CommandDescription
pip config listShow the current configuration
pip config set global.index-url URLSet a default index URL
pip install --no-cache-dir packageInstall without using the cache
pip cache dirShow the cache location
pip cache infoShow cache size and counts
pip cache purgeClear the wheel cache

Use these references for pip and Python workflows.

GuideDescription
Install pip on DebianInstall pip3 on Debian 11, 12, and 13
Install pip on UbuntuInstall pip3 on Ubuntu
Python Virtual EnvironmentsCreate and use isolated environments
pip vs aptWhen to use pip or the system package manager