python config_error ai_generated true

错误:无法为 mypkg 构建 wheel,而这是安装基于 pyproject.toml 的项目所必需的 × 获取构建 wheel 所需的要求未成功运行。 ╰─> 后端不可用:无法导入 'setuptools.build_meta'

ERROR: Could not build wheels for mypkg, which is required to install pyproject.toml-based projects × Getting requirements to build wheel did not run successfully. ╰─> [1 lines of output] BackendUnavailable: Cannot import 'setuptools.build_meta'

ID: python/pyproject-toml-missing-build-backend

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
0证据数
2024-08-30首次发现

版本兼容性

版本状态引入弃用备注
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

根因分析

声明的 PEP 517 构建后端无法在隔离构建环境中导入,通常因为缺少 setuptools,或 pyproject.toml 指定的后端未列入 `[build-system] requires`。

English

The declared PEP 517 build backend cannot be imported in the isolated build env, typically because setuptools is missing or the pyproject.toml names a backend not listed in `[build-system] requires`.

generic

解决方案

  1. 90% 成功率
    Fix pyproject.toml so `[build-system] requires = ["setuptools>=61", "wheel"]` and `build-backend = "setuptools.build_meta"`, then rebuild.
  2. 75% 成功率
    Bypass isolation for a quick local build: `pip install --no-build-isolation .` after installing setuptools/wheel in the current env.

无效尝试

常见但无效的做法:

  1. 92% 失败

    Unrelated to the backend import failure.

  2. 80% 失败

    Build isolation ignores the outer env's site-packages by design.