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

  × 获取构建 wheel 的要求未能成功运行。
  │ 退出码：1
  ╰─> ModuleNotFoundError：没有名为 'flit_core' 的模块

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

## 根因

项目的 pyproject.toml 声明了一个 PEP 517 构建后端（flit_core、hatchling、poetry-core），但该后端未安装，且由于离线模式或缺少索引而无法获取。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   # Inspect the backend
python - <<'PY'
import tomllib, pathlib
print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['build-system'])
PY
# Then install it
pip install flit_core
pip install .
   ```
2. **** (90% 成功率)
   ```
   unset PIP_NO_BUILD_ISOLATION
unset PIP_NO_INDEX
pip install --index-url https://pypi.org/simple .
   ```

## 无效尝试

- **** — Disables isolation but flit_core still isn't in the current environment, so the same ModuleNotFoundError occurs. (85% 失败率)
- **** — The missing module is the declared backend (flit_core), not setuptools/wheel. (90% 失败率)
