python config_error ai_generated true

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2025-07-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

Root Cause

The requirement line has a malformed version specifier, often a single `=` instead of `==`, or a space between operators.

generic

中文

需求行的版本说明符格式错误,通常是使用了单个 `=` 而非 `==`,或运算符之间有空格。

Workarounds

  1. 98% success
    Change `requests >=2.0 <3.0` to `requests>=2.0,<3.0`
  2. 90% success
    python -c "from packaging.requirements import Requirement; [Requirement(l.strip()) for l in open('requirements.txt') if l.strip() and not l.startswith('#')]"

Dead Ends

Common approaches that don't work:

  1. 90% fail

    requirements.txt is parsed by pip, not the shell; quoting does not change the grammar.

  2. 85% fail

    The parser is strict by design; upgrading does not accept invalid syntax.

  3. 95% fail

    The error occurs during parsing, before resolution.