python
module_error
ai_generated
true
ModuleNotFoundError: No module named 'distutils' File ".../setuptools/_distutils/__init__.py", line 1, in <module>
ID: python/setuptools-no-module-named-distutils
80%Fix Rate
90%Confidence
0Evidence
2024-01-08First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.12 | active | — | — | — |
| 3.13 | active | — | — | — |
Root Cause
Python 3.12 removed the stdlib `distutils`. Older setuptools versions that rely on it break; also affects packages importing distutils directly.
generic中文
Python 3.12 移除了标准库 `distutils`。依赖它的旧版 setuptools 会出错;也影响直接导入 distutils 的包。
Workarounds
-
90% success
python -m pip install --upgrade 'setuptools>=68' wheel python -m pip install <package>
-
70% success
export SETUPTOOLS_USE_DISTUTILS=local python -m pip install --upgrade setuptools
Dead Ends
Common approaches that don't work:
-
95% fail
There is no installable `distutils` package on PyPI; it was a stdlib module.
-
60% fail
If setuptools is already installed but old, pip may not upgrade it in the same invocation that fails.