python
config_error
ai_generated
true
错误:pyproject.toml 配置无效:`project`。配置错误:`project.version` 必须是字符串,实际为 `float`。
ERROR: Invalid pyproject.toml config: `project`. configuration error: `project.version` must be a string, was `float`
ID: python/pip-install-invalid-pyproject-toml
80%修复率
89%置信度
0证据数
2024-09-30首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
| 3.13 | active | — | — | — |
根因分析
TOML 将 `version = 1.0` 解析为浮点数,但 PEP 621 要求 version 字段为字符串。
English
TOML parses `version = 1.0` as a float, but PEP 621 requires the version field to be a string.
解决方案
-
97% 成功率
Quote the version in pyproject.toml: `version = "1.0"` (or use dynamic version via setuptools_scm).
-
94% 成功率
Validate before building: `python -c "import tomllib,pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])"`.
无效尝试
常见但无效的做法:
-
90% 失败
The pyproject.toml validation happens before build isolation settings matter.
-
85% 失败
Newer setuptools enforces the same PEP 621 type rules; the error persists.