ModuleNotFoundError: No module named 'distutils'
Python 3.12 removed distutils; old packages or tools that import it fail.
Seen on:
Python
Meaning
distutils was deprecated in 3.10 and removed in 3.12. Old versions of numpy, node-gyp, virtualenv and setup.py scripts still import it.
Common causes
- Running old packages on Python 3.12+
- Old setup.py-based builds
- node-gyp using system Python 3.12
⚡ Quick fix
- Install setuptools (provides a distutils shim): pip install setuptools
- Upgrade the failing package
- Use Python 3.11 for legacy projects
Detailed fix by platform
Python
python -m pip install -U setuptools
How to diagnose
- Version — python --version
- Package — Which package imports distutils?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026