python
data_error
ai_generated
true
packaging.version.InvalidVersion:无效版本:'1.0.0-rc1+build.123'
packaging.version.InvalidVersion: Invalid version: '1.0.0-rc1+build.123'
ID: python/packaging-invalid-version-string
80%修复率
88%置信度
0证据数
2024-04-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
版本字符串不符合 PEP 440;本地版本标签在 '+' 后必须以数字开头。
English
The version string does not conform to PEP 440; local version labels must start with a digit after the '+'.
解决方案
-
95% 成功率
version = '1.0.0rc1+build123' # local label 'build123' starts with digit
-
0% 成功率
from packaging.version import Version; v = Version('1.0.0rc1+build123') # will raise error; fix the string first
无效尝试
常见但无效的做法:
-
50% 失败
Removing build metadata may lose important build information; parsing may still fail if other parts are invalid.
-
80% 失败
The version is still invalid per PEP 440; older libraries may not raise error but will parse incorrectly.