python install_error ai_generated true

ERROR: Invalid requirement: 'requests ==2.31.0'

ID: python/pip-invalid-requirement-double-equals-space

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-03-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

Pip's requirement parser treats a space between the package name and the version specifier as a separate token, so 'requests ==2.31.0' is parsed as two invalid requirements.

generic

中文

pip 的需求解析器将包名与版本说明符之间的空格视为独立 token,因此 'requests ==2.31.0' 被解析为两个无效需求。

Workarounds

  1. 99% success
    Remove the space: pip install requests==2.31.0
  2. 99% success
    Use the PEP 508 form with no space: pip install 'requests==2.31.0'
  3. 98% success
    Put it in requirements.txt with no space: echo 'requests==2.31.0' > requirements.txt && pip install -r requirements.txt

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Quoting preserves the space; pip still sees the invalid token split and raises the same Invalid requirement error.

  2. 90% fail

    The shell passes a literal backslash-space to pip, which is not a valid requirement character and still fails parsing.

  3. 95% fail

    The syntax error is independent of the shell/terminal; the malformed requirement string is the cause.