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

- **ID:** `pip/pyproject-toml-build-backend-missing`
- **领域:** pip
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 24.1 | active | — | — |
| setuptools 68.0 | active | — | — |
| Python 3.11 | active | — | — |

## 解决方案

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"
   ```

## 无效尝试

- **** — Upgrading pip does not add the hook; the build backend must support it. (90% 失败率)
- **** — Deleting pyproject.toml and using setup.py directly may work but breaks build system standardization and can cause other issues. (70% 失败率)
- **** — Using 'pip install --no-build-isolation' does not bypass the hook requirement; it still fails. (95% 失败率)
