# 在 pip install -e . 期间出现 ModuleNotFoundError：没有名为 'setuptools' 的模块（pyproject.toml 构建后端）

- **ID:** `python/pip-build-isolation-missing-setuptools`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pyproject.toml 声明 setuptools.build_meta 作为后端，但构建隔离环境或项目的 build-system.requires 未包含 setuptools。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Declare the build requirement in pyproject.toml:
[build-system]
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"
   ```
2. **** (90% 成功率)
   ```
   Install build deps explicitly then build:
pip install setuptools wheel build
python -m build
   ```

## 无效尝试

- **** — Uses the current env, which may also lack setuptools or have an incompatible version; masks the real config bug. (65% 失败率)
- **** — Installs in the outer env but build isolation still creates a fresh env without it. (75% 失败率)
