# 错误：元数据生成失败
× 生成包元数据时遇到错误。

- **ID:** `python/pip-install-metadata-generation-failed`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pip 使用 PEP 517 构建隔离在独立环境中构建 wheel 元数据。如果构建后端（setuptools、hatchling、poetry-core）缺失或构建依赖未在 pyproject.toml 中声明，元数据生成会在实际安装前失败。

## 版本兼容性

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

## 解决方案

1. **** (85% 成功率)
   ```
   pip install setuptools wheel
pip install --no-build-isolation ./mypackage
   ```
2. **** (90% 成功率)
   ```
   [build-system]
requires = ["setuptools>=64", "wheel", "cython"]
build-backend = "setuptools.build_meta"
   ```
3. **** (80% 成功率)
   ```
   pip install -v ./mypackage 2>&1 | grep -A5 'Error'
   ```

## 无效尝试

- **** — Disables isolation but the missing build dependency is still not present in the current environment, so the backend import fails anyway. (55% 失败率)
- **** — The failure is in the build backend invocation, not a corrupted download; clearing cache does not add missing build deps. (70% 失败率)
- **** — Newer pip still respects pyproject.toml build-system requirements; the missing dependency is unchanged. (60% 失败率)
