python
module_error
ai_generated
true
ModuleNotFoundError: No module named 'distutils'
ID: python/setuptools-missing-distutils
80%Fix Rate
88%Confidence
0Evidence
2024-04-02First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.12 | active | — | — | — |
| 3.13 | active | — | — | — |
Root Cause
Python 3.12 removed the stdlib distutils module. Packages or setup.py scripts that import distutils (directly or via old setuptools) fail unless setuptools provides the distutils shim.
generic中文
Python 3.12 移除了标准库 distutils 模块。直接导入 distutils(或经由旧版 setuptools)的包或 setup.py 会失败,除非 setuptools 提供 distutils 兼容层。
Workarounds
-
85% success
pip install --upgrade 'setuptools>=68' # setuptools injects a distutils shim via SETUPTOOLS_USE_DISTUTILS=local
-
70% success
export SETUPTOOLS_USE_DISTUTILS=local pip install <pkg>
-
78% success
pyenv install 3.11.9 && pyenv local 3.11.9 pip install <pkg>
Dead Ends
Common approaches that don't work:
-
95% fail
distutils was a stdlib module, never a PyPI package; the install fails.
-
95% fail
No such distribution exists.
-
80% fail
Very old setuptools is incompatible with Python 3.12 in other ways.