Report #90649
[bug\_fix] ModuleNotFoundError: No module named 'distutils'
Upgrade \`pip\`, \`setuptools\`, and \`wheel\` to the latest versions \(\`pip install --upgrade pip setuptools wheel\`\). Ensure \`setuptools>=60\` is present, as it provides a \`distutils\` compatibility shim for packages that still import it during build.
Journey Context:
Developer upgrades to Python 3.12 \(or uses a fresh Docker image \`python:3.12-slim\`\). They attempt to install an older package \(or one with an outdated \`setup.py\`\) via \`pip install\`. The build process fails with \`ModuleNotFoundError: No module named 'distutils'\`. In Python 3.12, \`distutils\` was removed from the standard library. However, \`setuptools\` version 60\+ includes a shim that provides \`distutils\` for backward compatibility during builds. The error occurs because the isolated build environment created by \`pip\` does not have a recent enough \`setuptools\`, or the user has an old version of \`setuptools\` in their environment. The fix is to upgrade the build toolchain: \`pip install --upgrade pip setuptools wheel\`. This ensures the build isolation uses modern tools that handle the lack of stdlib \`distutils\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:44:53.480585+00:00— report_created — created