# ModuleNotFoundError：没有名为 'setuptools._distutils.command.build_ext' 的模块

- **ID:** `python/setup-py-install-requires-not-found`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

部分安装或降级后的 setuptools 缺少内置的 _distutils 子模块，通常发生在升级失败或 distutils 导入冲突之后。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   pip uninstall -y setuptools
pip install --no-cache-dir 'setuptools>=68'
python -c "from setuptools._distutils.command.build_ext import build_ext; print('ok')"
   ```
2. **** (90% 成功率)
   ```
   python -m venv .venv && source .venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install .
   ```

## 无效尝试

- **** — No such package on PyPI; pip returns 'No matching distribution found'. (95% 失败率)
- **** — --no-deps can leave an inconsistent setuptools install if any dependency was previously removed. (70% 失败率)
