Report #100056
[bug\_fix] \`ModuleNotFoundError: No module named 'distutils'\` or build failure because setuptools no longer bundles distutils on Python 3.12\+
Ensure \`setuptools\` is installed and up to date in the build environment \(\`pip install --upgrade setuptools wheel\`\), and that \`pyproject.toml\` declares it as a build requirement. If a third-party package still imports \`distutils\` directly, patch or upgrade that package; do not downgrade Python. Use \`pip install --no-build-isolation\` only as a temporary workaround with all build deps present.
Journey Context:
A developer upgrades to Python 3.12 and tries to install an older package that imports \`distutils.core\` during its \`setup.py\`. The build crashes with \`ModuleNotFoundError: No module named 'distutils'\`. They search and learn that Python 3.10 deprecated distutils and Python 3.12 removed the standard-library module, but setuptools now provides a vendored shim. The package's \`setup.py\` assumes distutils exists because it never declared a build backend. Upgrading setuptools and adding \`\[build-system\] requires = \["setuptools>=68", "wheel"\]\` gives the build the shim it needs. The fix works because modern setuptools supplies its own \`distutils\` compatibility layer, but only when it is explicitly the build backend.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-01T04:34:50.443839+00:00— report_created — created