python install_error ai_generated true

ERROR: Could not build wheels for foo, which is required to install pyproject.toml-based projects × Preparing metadata (pyproject.toml) did not run successfully. ╰─> BackendUnavailable: Cannot import 'setuptools.build_meta'

ID: python/pip-build-backend-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2024-05-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

Root Cause

The build backend declared in pyproject.toml [build-system].build-backend cannot be imported inside the isolated build environment, usually because the backend package is not listed in [build-system].requires.

generic

中文

pyproject.toml [build-system].build-backend 中声明的构建后端无法在隔离的构建环境中导入,通常是因为后端包未列入 [build-system].requires。

Workarounds

  1. 95% success
    Add the backend to requires in pyproject.toml:
      [build-system]
      requires = ["setuptools>=61", "wheel"]
      build-backend = "setuptools.build_meta"
    For hatchling: requires = ["hatchling"], build-backend = "hatchling.build"
  2. 80% success
    If you only consume the package, install the backend manually then build without isolation:
      pip install setuptools wheel
      pip install --no-build-isolation foo

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Without isolation, the backend must already be installed in your env; if it is not, the same error occurs.

  2. 90% fail

    pip version does not affect whether the build backend is importable.