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

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

## 根因

Python 3.12 移除了标准库的 distutils 模块。导入 distutils 的旧版 setuptools 和遗留 setup.py 脚本会失败。setuptools >= 60 提供了内置的 distutils 兼容层，但前提是 SETUPTOOLS_USE_DISTUTILS 未设置为 stdlib。

## 版本兼容性

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

## 解决方案

1. **** (92% 成功率)
   ```
   pip install --upgrade 'setuptools>=69' && export SETUPTOOLS_USE_DISTUTILS=local
   ```
2. **** (80% 成功率)
   ```
   pip install standard-distutils  # or use setuptools>=60 which vendors it
   ```
3. **** (85% 成功率)
   ```
   pyenv install 3.11.9 && pyenv local 3.11.9
   ```

## 无效尝试

- **** — No such package exists on PyPI; distutils was a stdlib module, not a distributable package. (95% 失败率)
- **** — Old setuptools (<60) does not provide the shim, so the import still fails downstream. (70% 失败率)
