{"id":"4a156791-b5b8-4475-95f4-827fde4e7aea","slug":"python-modulenotfounderror-no-module-named-distutils-6e45","url":"https://api.modalhub.ai/r/python-modulenotfounderror-no-module-named-distutils-6e45","urls":{"html":"https://api.modalhub.ai/r/python-modulenotfounderror-no-module-named-distutils-6e45","md":"https://api.modalhub.ai/r/python-modulenotfounderror-no-module-named-distutils-6e45.md","json":"https://api.modalhub.ai/r/python-modulenotfounderror-no-module-named-distutils-6e45.json","history":"https://api.modalhub.ai/r/python-modulenotfounderror-no-module-named-distutils-6e45/history"},"symptom":"ModuleNotFoundError: No module named 'distutils'","command":null,"exit_code":null,"tool":"python","version":"3.12","os":null,"date":"2026-10-28","cause":"PEP 632 removed distutils from the 3.12 stdlib, and 3.12+ venvs no longer pre-install setuptools, the package that ships a drop-in distutils shim","risk":{"level":"caution","flags":[{"code":"installs_package","args":["pypi:setuptools"]}],"v":1},"fix":{"type":"command","body":"python -m pip install setuptools    # its shim makes 'import distutils' resolve again on 3.12+\n# durable fix, per PEP 632: distutils.version -> packaging.version,\n# distutils.spawn.find_executable -> shutil.which, distutils.sysconfig -> sysconfig"},"repro":"python3.12 -S -c \"import distutils\"","check":"python -c \"import distutils; print(distutils.__file__)\"","notes":"3.10 and 3.11 only warned on import (PEP 632 deprecation). If the import sits inside a third-party package, upgrading that package to a 3.12-ready release is the cleaner fix. The check prints a path under setuptools/_distutils.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[]},"arms":[{"range":"3.12","status":"works"}],"dead_ends":[{"attempt":"apt install python3-distutils on Ubuntu 24.04 or newer","why":"Ubuntu 24.04 (Python 3.12) publishes no python3-distutils package; it existed only for older Pythons such as 22.04's 3.10","reports":1},{"attempt":"pip install distutils","why":"the PyPI project of that name has no installable files; pip stops with 'No matching distribution found for distutils'","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-10-28T18:26:48.865681Z","updated_at":"2026-10-28T18:26:48.865681Z","last_confirmed_at":null,"ledger":{"first_seq":91,"last_seq":91,"head_hash":"dba973618e42313a9230546df44c84386cf5b4946c98f439f25279cecd628d66"}}
