python config_error ai_generated true

错误:无法打开需求文件:[Errno 2] 没有那个文件或目录:'requirements/base.txt'

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

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

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

版本兼容性

版本状态引入弃用备注
3.x active

根因分析

-r 路径相对于当前工作目录解析,而不是相对于包含 -r 行的文件。

English

The -r path is resolved relative to the current working directory, not to the file that contains the -r line.

generic

解决方案

  1. 98% 成功率
    cd /path/to/project
    pip install -r requirements/base.txt
  2. 95% 成功率
    # requirements.txt at project root
    -r requirements/base.txt
    -r requirements/dev.txt
    pip install -r requirements.txt

无效尝试

常见但无效的做法:

  1. 90% 失败

    --no-index affects package lookup, not file resolution.

  2. 85% 失败

    MANIFEST.in is for sdist contents, not for pip's requirements resolution.

  3. 60% 失败

    Changes the base for resolution but may break other relative paths in the same file.