python data_error ai_generated true

错误:无效需求:'-e git+https://github.com/org/repo.git@main#egg=foo'(来自 requirements.txt 第 3 行) 提示:看起来像路径。文件 'requirements.txt' 不存在。

ERROR: Invalid requirement: '-e git+https://github.com/org/repo.git@main#egg=foo' (from line 3 of requirements.txt) Hint: It looks like a path. File 'requirements.txt' does not exist.

ID: python/pip-requirement-parse-invalid-editable

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

版本兼容性

版本状态引入弃用备注
3.8+ active — — —

根因分析

pip 错误解析需求行,通常由于 -e 后多余空格、BOM/编码问题,或该行被当作参数而非需求读取。

English

pip parsed a requirement line incorrectly, often due to a stray space after -e, a BOM/encoding issue, or the line being read as an argument rather than a requirement.

generic

解决方案

  1. 92% 成功率
    # requirements.txt
    -e git+https://github.com/org/repo.git@main#egg=foo
    # ensure UTF-8 without BOM; one requirement per line
  2. 88% 成功率
    python -c "import sys; open('requirements.txt', encoding='utf-8-sig').read()"
    # convert BOM:
    sed -i '1s/^\xEF\xBB\xBF//' requirements.txt
    pip install -r requirements.txt

无效尝试

常见但无效的做法:

  1. 70% 失败

    Loses editable mode; changes how the package resolves imports and breaks local development workflow.

  2. 85% 失败

    pip does not strip shell-style quotes from requirements lines; the quoted string becomes an invalid requirement.