PEP 632 removed distutils from the standard library in Python 3.12 (released October 2023). Any build script or runtime import of distutils fails on 3.12 and later with ModuleNotFoundError: No module named 'distutils', and the failure usually surfaces from a transitive dependency rather than from your own code.
setuptools ships a vendored copy and registers it under the distutils name, so installing setuptools restores the import on 3.12 and 3.13. Confirm the state of an interpreter with python -c "import distutils; print(distutils.__file__)" and look at whether the path lands inside setuptools.
The detail that catches people is virtual environments. As of 3.12 python -m venv no longer installs setuptools by default, so a fresh venv has no distutils at all even though the same machine's system Python may still import it. The durable fix is to port the code to packaging, sysconfig, and shutil instead of relying on the setuptools shim, which is itself scheduled for removal.