python
config_error
ai_generated
true
ERROR: Invalid requirement: 'requests==2.31.0' Hint: = is not a valid operator. Did you mean == ?
ID: python/pip-invalid-requirement-parsing-error
80%Fix Rate
88%Confidence
0Evidence
2024-02-14First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
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.
generic中文
requirements 文件或命令行参数中包含格式错误的版本说明符,最常见的是使用单个 '=' 而非 '==',或版本约束内有多余的逗号/空格,导致打包解析器拒绝。
Workarounds
-
98% success
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% success
Shell metacharacters like '>' and '<' must be quoted: pip install 'requests>=2.28,<3'
Dead Ends
Common approaches that don't work:
-
90% fail
The parser is behaving correctly; the requirement string is genuinely invalid regardless of pip version.
-
85% fail
The error is in the requirement text, not the environment, so a fresh venv reproduces it identically.
-
80% fail
--no-deps only skips dependency resolution, not parsing of the top-level requirement.