python
module_error
ai_generated
true
ModuleNotFoundError: No module named 'distutils'
ID: python/setuptools-distutils-removed-python312
80%Fix Rate
90%Confidence
0Evidence
2024-02-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.12 | active | — | — | — |
Root Cause
Python 3.12 removed the stdlib distutils module. Older setuptools versions and legacy setup.py scripts that import distutils directly fail. setuptools >= 60 provides a vendored distutils shim but only if SETUPTOOLS_USE_DISTUTILS is not set to stdlib.
generic中文
Python 3.12 移除了标准库的 distutils 模块。导入 distutils 的旧版 setuptools 和遗留 setup.py 脚本会失败。setuptools >= 60 提供了内置的 distutils 兼容层,但前提是 SETUPTOOLS_USE_DISTUTILS 未设置为 stdlib。
Workarounds
-
92% success
pip install --upgrade 'setuptools>=69' && export SETUPTOOLS_USE_DISTUTILS=local
-
80% success
pip install standard-distutils # or use setuptools>=60 which vendors it
-
85% success
pyenv install 3.11.9 && pyenv local 3.11.9
Dead Ends
Common approaches that don't work:
-
95% fail
No such package exists on PyPI; distutils was a stdlib module, not a distributable package.
-
70% fail
Old setuptools (<60) does not provide the shim, so the import still fails downstream.