# ModuleNotFoundError: No module named 'distutils'

During handling of the above exception, another exception occurred:

ImportError: cannot import name 'distutils' from setuptools

- **ID:** `python/setuptools-distutils-removed`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Python 3.12 removed distutils from the standard library; setuptools' shim (`setuptools._distutils`) is not active because setuptools is too old or the environment shadows it.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Upgrade setuptools to a version that provides the distutils shim: `pip install --upgrade 'setuptools>=68'`.
   ```
2. **** (70% success)
   ```
   Set the env var `SETUPTOOLS_USE_DISTUTILS=stdlib` is wrong for 3.12; instead ensure `SETUPTOOLS_USE_DISTUTILS=local` and that setuptools is imported before distutils.
   ```

## Dead Ends

- **** — No such package exists on PyPI; distutils was bundled, not a standalone distribution. (98% fail)
- **** — Not possible without recreating the venv; the interpreter version is fixed. (90% fail)
