# 错误：元数据生成失败

× 生成包元数据时遇到错误。
╰─> 参见上面的输出。

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

## 根因

pip 的 PEP 517 隔离构建无法生成元数据，因为包的 setup.py/构建后端抛出了异常（常见原因：缺少依赖、setup.py 语法错误或包无法导入）。

## 版本兼容性

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

## 解决方案

1. **** (85% 成功率)
   ```
   Re-run with verbose output to see the real exception: `pip install -v <pkg>`. The actual error (e.g. `ModuleNotFoundError` inside setup.py) appears a few lines above.
   ```
2. **** (70% 成功率)
   ```
   Install the build backend's runtime deps manually, or use legacy build: `pip install --no-build-isolation <pkg>` after `pip install setuptools wheel`.
   ```

## 无效尝试

- **** — The failure happens during metadata generation, not from a corrupted cache. (90% 失败率)
- **** — The same source distribution is fetched and fails identically. (70% 失败率)
