python config_error ai_generated true

错误:无效的依赖项:'git+https://github.com/org/repo.git#egg=my-pkg&subdirectory=src'

ERROR: Invalid requirement: 'git+https://github.com/org/repo.git#egg=my-pkg&subdirectory=src'

ID: python/pip-egg-fragment-not-supported

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

版本兼容性

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

根因分析

egg 片段包含多个用 '&' 连接参数;pip 的依赖解析器只接受 URL 片段中的单个 #egg=name 或 #subdirectory=。

English

The egg fragment contains multiple '&'-joined parameters; pip's requirement parser accepts only a single #egg=name or #subdirectory= in the URL fragment.

generic

解决方案

  1. 95% 成功率
    # requirements.txt
    git+https://github.com/org/[email protected]#subdirectory=src
    # or
    git+https://github.com/org/[email protected]#egg=my-pkg
  2. 85% 成功率
    pip install 'git+https://github.com/org/[email protected]' --config-settings editable_mode=compat
    # or clone + install
    pip install ./repo/src

无效尝试

常见但无效的做法:

  1. 90% 失败

    Quotes become part of the URL and are still parsed as an invalid requirement.

  2. 80% 失败

    The parser still sees two fragment parameters after decoding and rejects the requirement.