python data_error ai_generated true

pkg_resources.extern.packaging.requirements.InvalidRequirement: 期望结尾或分号(版本说明符之后) foo>=1.0<2.0 ~~~~^

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

ID: python/setuptools-version-parse-error-invalid-requirement

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

版本兼容性

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

根因分析

某个依赖字符串包含两个未用逗号分隔的版本说明符(如 `>=1.0<2.0`),PEP 508 解析器会拒绝。

English

A requirement string contains two version specifiers without a comma (e.g. `>=1.0<2.0`), which the PEP 508 parser rejects.

generic

解决方案

  1. 98% 成功率
    Insert a comma between specifiers: `foo>=1.0,<2.0` in install_requires / pyproject.toml.
  2. 90% 成功率
    Validate requirements with `python -c "from packaging.requirements import Requirement; Requirement('foo>=1.0,<2.0')"` before packaging.

无效尝试

常见但无效的做法:

  1. 90% 失败

    They are not shell metacharacters inside a Python string; escaping does nothing.

  2. 80% 失败

    The string is genuinely malformed regardless of parser version.