python data_error ai_generated true

错误:packaging.requirements.InvalidRequirement:预期字符串结尾,但需求 'requests>=2.25; extra == "security"' 中出现了 ';'

ERROR: packaging.requirements.InvalidRequirement: Expected end of string, got ';' in requirement 'requests>=2.25; extra == "security"'

ID: python/packaging-requirement-parsing-error

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

版本兼容性

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

根因分析

需求字符串错误地使用了 extras 语法;extras 必须用方括号括起来,而不是用分号分隔。

English

The requirement string uses extras syntax incorrectly; extras must be enclosed in square brackets, not separated by semicolon.

generic

解决方案

  1. 95% 成功率 Use correct extras syntax with square brackets
    Write: 'requests[security]>=2.25' (extras inside brackets).
  2. 90% 成功率 Use environment markers for conditional dependencies
    Write: 'requests>=2.25; extra == "security"' but note that this is for markers, not extras. For extras, use brackets.

无效尝试

常见但无效的做法:

  1. Removing the semicolon and extra entirely 70% 失败

    Loses the conditional requirement.

  2. Using a comma instead of semicolon 80% 失败

    Comma is not valid for extras syntax.