Error Knowledge Base PIP REQUIREMENTS_FILE_NOT_FOUND

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

pip was asked to install from a requirements file path that does not exist (wrong filename, wrong directory, or missing checkout).

Affected versions: All pip versions.

What This Error Means

pip was asked to install from a requirements file path that does not exist (wrong filename, wrong directory, or missing checkout).

How to Fix It

  1. Run the command from the directory containing the file, or pass the correct relative/absolute path to -r.
  2. Fix typos (requirements.txt vs requirement.txt).
  3. If the file truly doesn't exist, generate one only if appropriate: python -m pip freeze > requirements.txt (note: this captures your current environment, which may not match a project).

Why It Happens

  • You ran the command from a directory that doesn't contain the file.
  • The file is named differently (common typo: requirement.txt).
  • The repository checkout is incomplete or the file was not committed.

How to Verify

  1. Run python -m pip install -r requirements.txt and confirm pip begins installing packages.
  2. If you're using a custom path, confirm it resolves correctly: python -c 'import pathlib; print(pathlib.Path("path/to/requirements.txt").resolve())'.

Manual file path checks

  1. List files in your current directory: ls -la.
  2. Confirm the filename is exactly requirements.txt (plural is the common convention).
  3. If you are in CI, confirm the repo was checked out and your job runs from the right working directory.

Common CLI Output

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

How pip reads requirements files

  1. When you run pip install -r requirements.txt, pip opens the file path and parses each requirement line.
  2. If the path is wrong or the file isn't present in the current working directory, pip fails before it can install anything.

Prevention Tips

  • Keep requirements.txt in a predictable location and document it.
  • In CI, set the working directory explicitly before running pip.
  • Use lock files or pinned requirements for reproducibility where possible.

Where This Can Be Triggered

github.com/pypa/pip/blob/25.3/src/pip/_internal/req/req_file.py

pip reads requirements files from a URL or a local path, if opening the path fails, it raises an InstallationError with "Could not open requirements file: ...". - GitHub

# Assume this is a bare path.
try:
    with open(url, "rb") as f:
        raw_content = f.read()
except OSError as exc:
    raise InstallationError(f"Could not open requirements file: {exc}")

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list