python config_error ai_generated true

distutils.errors.DistutilsOptionError: error in 'extras_require' option: 'foo' must be a string or list of strings containing valid project/version requirement specifiers; Invalid specifier: '>=1.0, <2.0, !=1.5'

ID: python/setuptools-extras-require-parse-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
84%Confidence
0Evidence
2024-07-08First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

Root Cause

An extras_require entry uses a specifier set the installed packaging/setuptools cannot parse, often due to stray whitespace, a trailing comma, or a duplicate/conflicting operator.

generic

中文

extras_require 条目使用了已安装的 packaging/setuptools 无法解析的说明符集合,常由于多余空格、尾随逗号或重复/冲突的运算符。

Workarounds

  1. 95% success
    Simplify the specifier to a valid PEP 440 set, e.g. `'>=1.0,<2.0,!=1.5'` (no spaces, no trailing comma).
  2. 90% success
    Validate with `python -c "from packaging.specifiers import SpecifierSet; SpecifierSet('>=1.0,<2.0')"`.

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Whitespace is not the issue; the specifier set itself is malformed.

  2. 75% fail

    Shifts the same parse error to a different field.