Report #104488
[bug\_fix] ModuleNotFoundError: No module named 'distutils'
Install \`setuptools\` \(which provides distutils\) via \`pip install setuptools\`, or use Python 3.12\+ where distutils is removed and migrate to \`setuptools\` or \`packaging\`.
Journey Context:
A developer upgraded to Python 3.12 and tried to run a legacy script that used \`from distutils.core import setup\`. They got \`ModuleNotFoundError: No module named 'distutils'\`. The script was a \`setup.py\` for an old package. The developer initially tried \`pip install distutils\` but that package is not available on PyPI. Research revealed that Python 3.12 removed the deprecated \`distutils\` module entirely \(PEP 632\). The fix is to replace \`distutils\` usage with \`setuptools\`, which provides the same functionality: \`from setuptools import setup\`. After updating the \`setup.py\` and installing \`setuptools\` \(usually bundled with pip, but can be explicit\), the error resolved. The root cause: Python's standard library dropped \`distutils\`; code must be updated to use \`setuptools\` or the \`packaging\` library.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-23T20:07:28.685140+00:00— report_created — created