/errors/pip/could-not-open-requirements-file
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
- tool
- pip
- exit code
- 1
- versions
- pip 20 – 26
- os
- any
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' means pip was given -r requirements.txt and no file with that name exists relative to the current directory. pip does not search parent folders or the script's location. Run the command from the folder that contains the file, or pass its full path: pip install -r path/to/requirements.txt.
Reproduce it
pip download reads requirements files with the same code as pip install, so it prints the same error without touching any environment:
pip download --disable-pip-version-check -d dl -r requirements.txtOutput · exit 1
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
Fix
Point -r at the real file. Paths inside a requirements file (-r base.txt, -c constraints.txt) are resolved relative to that file, not to the current directory:
mkdir -p app/requirements
echo "six==1.16.0" > app/requirements/base.txt
echo "-r base.txt" > app/requirements/dev.txt
pip download --disable-pip-version-check --no-deps -q -d dl -r app/requirements/dev.txt
ls dlOutput
six-1.16.0-py2.py3-none-any.whl
Where it usually happens
| Context | What to check |
|---|---|
| Terminal | pwd and ls: are you in the project root? |
| Dockerfile | COPY requirements.txt . comes before RUN pip install -r requirements.txt, and WORKDIR matches |
| GitHub Actions | actions/checkout ran first; working-directory points to the folder with the file |
| Heroku / PaaS buildpacks | requirements.txt is at the repository root, with that exact name |
| Windows | The file is not saved as requirements.txt.txt (hidden extensions in Explorer) |
If the project has a pyproject.toml and no requirements file, install it with pip install . (or pip install -e . for development) instead.