python
config_error
ai_generated
true
错误:无效的需求:'requests >=2.0 <3.0'(来自 requirements.txt 第 4 行) 提示:= 不是有效的运算符。您是指 == 吗?
ERROR: Invalid requirement: 'requests >=2.0 <3.0' (from line 4 of requirements.txt) Hint: = is not a valid operator. Did you mean == ?
ID: python/pip-requirement-parse-error
80%修复率
88%置信度
0证据数
2025-07-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
需求行的版本说明符格式错误,通常是使用了单个 `=` 而非 `==`,或运算符之间有空格。
English
The requirement line has a malformed version specifier, often a single `=` instead of `==`, or a space between operators.
解决方案
-
98% 成功率
Change `requests >=2.0 <3.0` to `requests>=2.0,<3.0`
-
90% 成功率
python -c "from packaging.requirements import Requirement; [Requirement(l.strip()) for l in open('requirements.txt') if l.strip() and not l.startswith('#')]"
无效尝试
常见但无效的做法:
-
90% 失败
requirements.txt is parsed by pip, not the shell; quoting does not change the grammar.
-
85% 失败
The parser is strict by design; upgrading does not accept invalid syntax.
-
95% 失败
The error occurs during parsing, before resolution.