ERROR pip build_error ai_generated true

错误:项目有 'pyproject.toml',但其构建后端缺少 'build_editable' 钩子。无法构建可编辑版本。构建后端不支持 'build_editable' 钩子。

ERROR: Project has a 'pyproject.toml' and its build backend is missing the 'build_editable' hook. Cannot build editable. The build backend does not support the 'build_editable' hook.

ID: pip/pep-660-editable-install-fails-no-build-backend

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
1证据数
2023-06-12首次发现

版本兼容性

版本状态引入弃用备注
pip 21.3 active
pip 23.0 active
pip 23.2.1 active

根因分析

pyproject.toml 中指定的构建后端(例如较旧版本的 setuptools 或自定义后端)未实现 PEP 660 的 `build_editable` 钩子,而该钩子是使用 `pip install -e` 进行可编辑安装所必需的。

English

The build backend specified in pyproject.toml (e.g., an older version of setuptools or a custom backend) does not implement the PEP 660 `build_editable` hook, which is required for editable installs using `pip install -e`.

generic

官方文档

https://peps.python.org/pep-0660/

解决方案

  1. 升级构建后端到支持 PEP 660 的版本。对于 setuptools:`pip install --upgrade setuptools>=64.0.0`。对于 flit:`pip install --upgrade flit_core>=3.8.0`。然后重试 `pip install -e .`。
  2. 临时切换到非可编辑安装:使用 `pip install .` 代替 `pip install -e .`。这将绕过 `build_editable` 钩子的要求。

无效尝试

常见但无效的做法:

  1. 90% 失败

    The `--no-build-isolation` flag does not add the missing `build_editable` hook; it only prevents pip from creating a temporary build environment. The backend still lacks the hook.

  2. 85% 失败

    This config setting is for setuptools specifically and only works if the backend already supports editable installs; it does not add the missing hook.