# 模块未找到错误：没有名为 'distutils' 的模块

- **ID:** `python/setuptools-missing-distutils`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Python 3.12 移除了标准库 distutils 模块。直接导入 distutils（或经由旧版 setuptools）的包或 setup.py 会失败，除非 setuptools 提供 distutils 兼容层。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.12 | active | — | — |
| 3.13 | active | — | — |

## 解决方案

1. **** (85% 成功率)
   ```
   pip install --upgrade 'setuptools>=68'
# setuptools injects a distutils shim via SETUPTOOLS_USE_DISTUTILS=local
   ```
2. **** (70% 成功率)
   ```
   export SETUPTOOLS_USE_DISTUTILS=local
pip install <pkg>
   ```
3. **** (78% 成功率)
   ```
   pyenv install 3.11.9 && pyenv local 3.11.9
pip install <pkg>
   ```

## 无效尝试

- **** — distutils was a stdlib module, never a PyPI package; the install fails. (95% 失败率)
- **** — No such distribution exists. (95% 失败率)
- **** — Very old setuptools is incompatible with Python 3.12 in other ways. (80% 失败率)
