python config_error ai_generated true

错误:无法打开 requirements 文件:[Errno 2] 没有这样的文件或目录:'requirements.txt'

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

ID: python/pip-req-file-not-found

其他格式: JSON · Markdown 中文 · English
80%修复率
90%置信度
0证据数
2024-03-05首次发现

版本兼容性

版本状态引入弃用备注
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

根因分析

pip 是从不包含 requirements 文件的目录调用的,或文件名拼写错误(例如 requirements-dev.txt)。

English

pip is invoked from a directory that does not contain the requirements file, or the filename is misspelled (e.g. requirements-dev.txt).

generic

解决方案

  1. 98% 成功率
    pwd
    ls requirements*.txt
    pip install -r "$(pwd)/requirements.txt"
  2. 90% 成功率
    pip freeze > requirements.txt
    pip install -r requirements.txt

无效尝试

常见但无效的做法:

  1. 95% 失败

    The error is a missing file, not a pip bug; upgrading does not create the file.

  2. 95% 失败

    --no-cache-dir affects the HTTP cache, not file lookup; the same FileNotFoundError occurs.