python config_error ai_generated true

distutils.errors.DistutilsOptionError: 'extras_require' 选项错误:'foo' 必须是包含有效项目/版本要求说明符的字符串或字符串列表;无效说明符:'>=1.0, <2.0, !=1.5'

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

其他格式: JSON · Markdown 中文 · English
80%修复率
84%置信度
0证据数
2024-07-08首次发现

版本兼容性

版本状态引入弃用备注
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

根因分析

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

English

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

解决方案

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

无效尝试

常见但无效的做法:

  1. 85% 失败

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

  2. 75% 失败

    Shifts the same parse error to a different field.