Skip to content

pip: Python Package Installer

pip is the Python Package Authority’s (PyPA) standard package installer. It enables installing and managing Python packages from the Python Package Index (PyPI) and other package indexes. pip comes with modern Python installations and serves as the default tool for package operations in the Python ecosystem.

While pip remains Python’s default package installer, many workflows benefit from newer tools like uv that provide better performance and more integrated functionality.

Key Features

pip provides essential package management capabilities:

  • Installing packages from PyPI and other indexes
  • Uninstalling packages from environments
  • Managing requirements files
  • Installing packages in editable mode for development
  • Generating PEP 751 pylock.toml lockfiles (experimental)
  • Installing from a pylock.toml lockfile via pip install -r pylock.toml (experimental)
  • Installing PEP 735 dependency groups
  • Installing dependencies declared with PEP 723 inline script metadata
  • Installing only a package’s dependencies without the package itself, via --only-deps
  • Experimental venv-based build isolation via --use-feature=venv-isolation, replacing the sitecustomize.py approach

Key Commands

Installing Packages

# Install latest version
pip install requests

# Install specific version
pip install requests==2.31.0

# Install from requirements file
pip install -r requirements.txt

# Install a PEP 735 dependency group from pyproject.toml
pip install --group dev

# Install dependencies declared in a PEP 723 script
pip install --requirements-from-script script.py

# Install current directory in editable mode
pip install -e .

# Install only a package's dependencies, not the package itself (pip 26.2+)
pip install . --only-deps

Managing Requirements

# Output installed packages
pip freeze > requirements.txt

# Install from requirements
pip install -r requirements.txt

# Generate a PEP 751 lockfile (experimental)
pip lock -r requirements.txt -o pylock.toml

# Install from a PEP 751 lockfile (experimental, pip 26.1+)
pip install -r pylock.toml

Package Information

# List installed packages
pip list

# Show package details
pip show requests

# Check environment for conflicts
pip check

Resolution Controls

# Only consider packages uploaded before a given date (pip 26.0+)
pip install --uploaded-prior-to 2025-01-01T00:00:00Z requests

# Use an ISO 8601 duration for a rolling cooldown window (pip 26.1+)
pip install --uploaded-prior-to P3D requests

# Exclude pre-releases for a specific package (pip 26.0+)
pip install --only-final fastapi

# Constrain build-time dependencies independently of runtime (pip 26.0+)
pip install --build-constraint build-constraints.txt -r requirements.txt

# Force re-fetch for a specific package, bypassing the index cache (pip 26.2+)
pip install --refresh-package=requests requests

# Disable automatic --require-hashes enforcement; allows mixing hashed and unhashed requirements (pip 26.2+)
pip install --no-require-hashes -r requirements.txt

Note

As of pip 26.2, constraints files (including PIP_CONSTRAINT) no longer apply to isolated build environments. Use --build-constraint or PIP_BUILD_CONSTRAINT to constrain build dependencies. PIP_CONSTRAINT remains the environment variable for --constraint; it still constrains the main install, not isolated build dependencies.

Cons

pip has limitations to consider:

  • Lockfile support is experimental, and pip lock does not yet cover environment markers or multi-platform resolution
  • Does not manage Python interpreters or virtual environments
  • Slower package operations than uv, which resolves and installs in parallel
  • Pip 26.1 dropped support for Python 3.9; the minimum runtime is now Python 3.10

Learn More

Related Tools

  • pip-tools — Advanced lockfile generation and management for pip
  • uv — Faster package manager with integrated Python and venv management
  • requirements.txt — Requirements file format reference

Guides

External Resources

Last updated on