πŸ“‹ Cheat Sheets
Β· 2 min read

pip Cheat Sheet β€” Install, Manage, and Freeze Python Packages


Some links in this article are affiliate links. We earn a commission at no extra cost to you when you purchase through them. Full disclosure.

Click any item to expand the explanation and examples.

πŸ“¦ Install & Uninstall

pip install <package> install
pip install requests                  # Latest version
pip install requests==2.31.0          # Exact version
pip install "requests>=2.28,<3.0"     # Version range
pip install requests flask pandas     # Multiple packages
pip install -r requirements.txt       # From requirements file
pip install -e .                      # Install current project in editable mode
pip install --upgrade requests        # Upgrade to latest
pip install --user requests           # Install for current user only
pip uninstall <package> install
pip uninstall requests
pip uninstall -y requests flask    # Skip confirmation

πŸ“‹ List & Info

pip list / pip show / pip freeze info
pip list                    # All installed packages
pip list --outdated         # Packages with newer versions
pip show requests           # Package details (version, location, deps)
pip freeze                  # All packages in requirements.txt format
pip freeze > requirements.txt  # Save to file
pip search / pip check info
pip check                   # Verify all dependencies are satisfied
pip cache purge             # Clear download cache
pip config list             # Show pip configuration

Note: pip search is disabled on PyPI. Use pypi.org to search for packages.

πŸ”’ Virtual Environments

venv β€” isolated Python environments venv

Always use a virtual environment. Never install packages globally.

# Create
python -m venv .venv

# Activate
source .venv/bin/activate        # macOS/Linux
.venv\Scripts\activate           # Windows

# Now pip installs into .venv/
pip install requests

# Deactivate
deactivate

# Add to .gitignore
echo ".venv/" >> .gitignore
requirements.txt workflow venv
# Save current packages
pip freeze > requirements.txt

# Install from file (on another machine or in CI)
pip install -r requirements.txt

# Typical requirements.txt
requests==2.31.0
flask==3.0.0
python-dotenv==1.0.0

See also: Python cheat sheet | Python complete guide | Python ModuleNotFoundError fix

Quick access: Raycast lets you search commands, snippets, and cheat sheets instantly from your keyboard. Free for Mac.

Related: Pip Install Error Fix

πŸ“˜