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.lockIn 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
pip install: Command Reference for CIReference for pip install in CI pipelines: installing packages, pinning versions, common flags, a GitHub Acti…
pip freeze: Pin the Environment Command ReferenceReference for pip freeze in CI: snapshotting installed versions into requirements.txt, excluding editable/VCS…
pip-compile (pip-tools): Lock Command ReferenceReference for pip-compile from pip-tools in CI: compiling requirements.in into a fully pinned requirements.tx…