# ModuleNotFoundError: 没有名为 'distutils' 的模块

在处理上述异常期间，又发生另一个异常：

ImportError: 无法从 setuptools 导入名称 'distutils'

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

## 根因

Python 3.12 从标准库中移除了 distutils；由于 setuptools 过旧或环境遮蔽，setuptools 的垫片（setuptools._distutils）未生效。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Upgrade setuptools to a version that provides the distutils shim: `pip install --upgrade 'setuptools>=68'`.
   ```
2. **** (70% 成功率)
   ```
   Set the env var `SETUPTOOLS_USE_DISTUTILS=stdlib` is wrong for 3.12; instead ensure `SETUPTOOLS_USE_DISTUTILS=local` and that setuptools is imported before distutils.
   ```

## 无效尝试

- **** — No such package exists on PyPI; distutils was bundled, not a standalone distribution. (98% 失败率)
- **** — Not possible without recreating the venv; the interpreter version is fixed. (90% 失败率)
