python config_error ai_generated true

packaging.requirements.InvalidRequirement: Expected end or semicolon (after version specifier) foo >= 1.0 < 2.0 ~~~~^

ID: python/setuptools-invalid-version-specifier

Also available as: JSON · Markdown · 中文
80%Fix Rate
89%Confidence
0Evidence
2024-04-23First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

A version constraint combines two operators without a comma, e.g. '>= 1.0 < 2.0'. PEP 440 requires a comma between specifiers.

generic

中文

版本约束组合了两个运算符而未使用逗号,例如 '>= 1.0 < 2.0'。PEP 440 要求说明符之间使用逗号。

Workarounds

  1. 99% success
    # bad
    foo >= 1.0 < 2.0
    # good
    foo>=1.0,<2.0
  2. 95% success
    # equivalent to >=1.0,<2.0 for a 1.x series
    foo~=1.0

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Quoting does not change the grammar the parser enforces.

  2. 85% fail

    Older packaging also rejects the same malformed specifier.