python
data_error
ai_generated
true
packaging.specifiers.InvalidSpecifier:无效的版本说明符:'>=1.0, <2.0,'
packaging.specifiers.InvalidSpecifier: Invalid specifier: '>=1.0, <2.0,'
ID: python/setuptools-invalid-version-specifier-normalize
80%修复率
85%置信度
0证据数
2024-08-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8+ | active | — | — | — |
根因分析
版本约束字符串包含尾随逗号或格式错误的运算符,packaging.specifiers 无法解析。常见于模板化的 requirements 或 install_requires 中的拼写错误。
English
A version constraint string contains a trailing comma or malformed operator that packaging.specifiers cannot parse. Often from templated requirements or a typo in install_requires.
解决方案
-
90% 成功率
from packaging.specifiers import SpecifierSet s = '>=1.0, <2.0,'.strip().rstrip(',') SpecifierSet(s) # raises if still invalid -
93% 成功率
# requirements.txt: one constraint per line, no trailing commas foo>=1.0,<2.0 # setup.cfg: # install_requires = # foo>=1.0,<2.0
无效尝试
常见但无效的做法:
-
80% 失败
Silently drops a real constraint, potentially installing an incompatible version that breaks at runtime.
-
85% 失败
Merges multiple constraints into one malformed token (e.g. '>=1.0<2.0'), still invalid.