# 错误：无法为 mypkg 构建 wheel，而这是安装基于 pyproject.toml 的项目所必需的

× 为 mypkg 构建 wheel（pyproject.toml）未能成功运行。
│ 退出代码：1
╰─> ModuleNotFoundError: 没有名为 'setuptools' 的模块

- **ID:** `python/setuptools-missing-build-system-requires`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

项目的 pyproject.toml 声明了 [build-system] 表，但其 'requires' 中缺少 setuptools（或声明为空列表），因此隔离的构建环境缺少该后端。

## 版本兼容性

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

## 解决方案

1. **** (97% 成功率)
   ```
   [build-system]
requires = ["setuptools>=68", "wheel"]
build-backend = "setuptools.build_meta"
   ```
2. **** (90% 成功率)
   ```
   python -m pip install 'setuptools>=68' wheel
python -m pip install --no-build-isolation mypkg
   ```

## 无效尝试

- **** — Build isolation creates a fresh env; the current venv's setuptools is not visible. (85% 失败率)
- **** — Then the build uses the current Python's setuptools, which may be absent or too old. (75% 失败率)
