python
config_error
ai_generated
true
错误:无效的需求:'requests==2.31.0' 提示:= 不是有效的运算符。您是否想用 == ?
ERROR: Invalid requirement: 'requests==2.31.0' Hint: = is not a valid operator. Did you mean == ?
ID: python/pip-invalid-requirement-parsing-error
80%修复率
88%置信度
0证据数
2024-02-14首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
requirements 文件或命令行参数中包含格式错误的版本说明符,最常见的是使用单个 '=' 而非 '==',或版本约束内有多余的逗号/空格,导致打包解析器拒绝。
English
The requirements file or command line argument contains a malformed version specifier, most commonly a single '=' instead of '==', or a stray comma/space inside the version constraint that the packaging parser rejects.
解决方案
-
98% 成功率
Replace single '=' with '==' and remove spaces around specifiers: # bad requests = 2.31.0 # good requests==2.31.0 # or use a range requests>=2.28,<3
-
95% 成功率
Shell metacharacters like '>' and '<' must be quoted: pip install 'requests>=2.28,<3'
无效尝试
常见但无效的做法:
-
90% 失败
The parser is behaving correctly; the requirement string is genuinely invalid regardless of pip version.
-
85% 失败
The error is in the requirement text, not the environment, so a fresh venv reproduces it identically.
-
80% 失败
--no-deps only skips dependency resolution, not parsing of the top-level requirement.