Skip to content
Latchkey

pip install -r requirements.txt: Command Reference

Restore a project entire dependency set from a requirements file.

pip install -r reads a requirements file and installs every listed package. It is the standard dependency-restore step in a pip-based CI job.

Common flags / usage

  • -r FILE -- install everything listed in FILE
  • multiple -r flags -- combine base and dev requirements
  • --require-hashes -- demand a hash for every requirement (hardened installs)
  • -c, --constraint FILE -- bound versions without installing extra packages
  • --no-deps -- install only the listed packages, not their transitive deps

Example

shell
- uses: actions/setup-python@v5
  with:
    python-version: '3.12'
    cache: 'pip'
    cache-dependency-path: requirements*.txt
- run: pip install -r requirements.txt -r requirements-dev.txt
# Hardened install from a hash-pinned lock:
- run: pip install --require-hashes -r requirements.lock

In CI

Point cache-dependency-path at your requirements files so the cache key invalidates when they change. A wrong working directory triggers "Could not open requirements file"; reference an explicit path like ./service/requirements.txt.

Key takeaways

  • pip install -r installs every package in a requirements file in one step.
  • Use --require-hashes with a hash-pinned lock for tamper-evident, reproducible installs.
  • Key the pip cache on the requirements files so it busts when dependencies change.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →