Skip to content

/errors/pip/could-not-open-requirements-file

ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · pip 26.2.1 fromupdated
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:

bash
pip download --disable-pip-version-check -d dl -r requirements.txt

Output · 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:

bash
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 dl

Output

six-1.16.0-py2.py3-none-any.whl

Where it usually happens

ContextWhat to check
Terminalpwd and ls: are you in the project root?
DockerfileCOPY requirements.txt . comes before RUN pip install -r requirements.txt, and WORKDIR matches
GitHub Actionsactions/checkout ran first; working-directory points to the folder with the file
Heroku / PaaS buildpacksrequirements.txt is at the repository root, with that exact name
WindowsThe 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.

Sources