pip install -r: Install from requirements.txt in CI
Install a whole requirements file in one command.
pip install -r reads a requirements file and installs every listed package. It is the standard way CI jobs restore a project’s dependencies.
What it does
Installs all packages listed in a requirements file. The file can pin exact versions, reference other files with -r, include hashes, and point at extra indexes.
Common usage
Terminal
pip install -r requirements.txt
pip install -r requirements.txt -r requirements-dev.txt
pip install --require-hashes -r requirements.lockCommon CI error: file not found
If the working directory is wrong, pip reports the requirements file is missing and the job fails immediately. Reference the file by an explicit path relative to the job’s working directory.
Terminal
# Failure:
# ERROR: Could not open requirements file:
# [Errno 2] No such file or directory: 'requirements.txt'
# Fix: point at the real path
pip install -r ./service/requirements.txtOptions
| Option | Does |
|---|---|
| -r, --requirement FILE | Install from the given requirements file |
| --require-hashes | Require a hash for every requirement |
| -c, --constraint FILE | Constrain versions without installing |
| --no-deps | Install only the listed packages |
Related guides
pip install: Usage, Options & Common CI ErrorsHow pip install works - installing packages, version specifiers, and the options you reach for, plus the CI f…
pip "Could not find a version that satisfies the requirement"Fix pip "Could not find a version that satisfies the requirement" / "No matching distribution found" in CI -…
uv pip compile: Generate a Pinned requirements.txtHow uv pip compile turns requirements.in into a fully pinned requirements.txt, the --generate-hashes flag, an…