python
config_error
ai_generated
true
ERROR: Invalid pyproject.toml config: `project`. configuration error: `project.version` must be a string, was `float`
ID: python/pip-install-invalid-pyproject-toml
80%Fix Rate
89%Confidence
0Evidence
2024-09-30First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
| 3.13 | active | — | — | — |
Root Cause
TOML parses `version = 1.0` as a float, but PEP 621 requires the version field to be a string.
generic中文
TOML 将 `version = 1.0` 解析为浮点数,但 PEP 621 要求 version 字段为字符串。
Workarounds
-
97% success
Quote the version in pyproject.toml: `version = "1.0"` (or use dynamic version via setuptools_scm).
-
94% success
Validate before building: `python -c "import tomllib,pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])"`.
Dead Ends
Common approaches that don't work:
-
90% fail
The pyproject.toml validation happens before build isolation settings matter.
-
85% fail
Newer setuptools enforces the same PEP 621 type rules; the error persists.