Python pip Package Manager Cheat Sheet

Command-line reference guide for pip. Learn to install, upgrade, uninstall, and manage Python packages and dependencies.

Installing & Managing Packages

Essential commands to acquire packages from the PyPI index and query local packages.

MethodSyntaxDescription
pip installpip install <package>Downloads and installs the specified package.
pip install --upgradepip install -U <package>Upgrades the package to its latest available version.
pip uninstallpip uninstall <package>Uninstalls the specified package from the active python library path.
pip listpip listLists all installed packages along with their version numbers.
pip showpip show <package>Displays detailed metadata information about a installed package.

Dependency Tracking & Caches

Freezing configurations, environment files, and caching adjustments.

MethodSyntaxDescription
pip freezepip freezeOutputs installed packages in requirements format (package==version).
pip install -rpip install -r requirements.txtInstalls all dependencies listed in the specified text file.
pip checkpip checkVerifies that installed packages have compatible dependencies.
pip cache purgepip cache purgeClears the local downloaded wheel cache storage.

Frequently Asked Questions

What is the difference between pip list and pip freeze?

pip list lists installed packages and their versions in a user-friendly format, while pip freeze prints them in the format package==version, suitable for writing to a requirements.txt file.

How do I isolate dependencies between different projects?

Use Python's built-in venv module to create a virtual environment, activate it, and run pip within that environment.

Keep Learning

Recommended Python Resources

Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.