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

Also available as: JSON · Markdown · 中文
80%Fix Rate
89%Confidence
0Evidence
2024-09-30First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
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

  1. 97% success
    Quote the version in pyproject.toml: `version = "1.0"` (or use dynamic version via setuptools_scm).
  2. 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:

  1. 90% fail

    The pyproject.toml validation happens before build isolation settings matter.

  2. 85% fail

    Newer setuptools enforces the same PEP 621 type rules; the error persists.