pip build_error ai_generated partial

错误:项目有 'pyproject.toml',但其构建后端缺少 'build_editable' 钩子。无法构建可编辑安装。项目的构建后端 'setuptools.build_meta' 没有 'build_editable' 钩子。

ERROR: Project has a 'pyproject.toml' and its build backend is missing the 'build_editable' hook. Cannot build editable. The project's build backend 'setuptools.build_meta' does not have a 'build_editable' hook.

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

其他格式: JSON · Markdown 中文 · English
82%修复率
87%置信度
1证据数
2024-03-05首次发现

版本兼容性

版本状态引入弃用备注
pip 24.1 active
setuptools 68.0 active
Python 3.11 active

根因分析

pyproject.toml 指定了一个构建后端(例如 setuptools.build_meta),该后端不支持 'build_editable' 钩子,而现代 pip 的 'pip install -e .' 需要此钩子。

English

The pyproject.toml specifies a build backend (e.g., setuptools.build_meta) that does not support the 'build_editable' hook, required for 'pip install -e .' with modern pip.

generic

官方文档

https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#editable-install

解决方案

  1. 升级 setuptools 到 64+ 版本,该版本支持 build_editable:'pip install --upgrade setuptools>=64' 然后重试可编辑安装。
  2. 临时使用非可编辑模式安装:'pip install .' 而不是 'pip install -e .'
  3. 在 pyproject.toml 中添加支持可编辑安装的自定义构建后端,例如使用 'hatchling' 或 'flit_core':
    [build-system]
    requires = ["hatchling"]
    build-backend = "hatchling.build"

无效尝试

常见但无效的做法:

  1. 90% 失败

    Upgrading pip does not add the hook; the build backend must support it.

  2. 70% 失败

    Deleting pyproject.toml and using setup.py directly may work but breaks build system standardization and can cause other issues.

  3. 95% 失败

    Using 'pip install --no-build-isolation' does not bypass the hook requirement; it still fails.