# ModuleNotFoundError: No module named 'distutils'

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

## Root Cause

Python 3.12 removed the stdlib distutils module. Packages or setup.py scripts that import distutils (directly or via old setuptools) fail unless setuptools provides the distutils shim.

## Version Compatibility

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

## Workarounds

1. **** (85% success)
   ```
   pip install --upgrade 'setuptools>=68'
# setuptools injects a distutils shim via SETUPTOOLS_USE_DISTUTILS=local
   ```
2. **** (70% success)
   ```
   export SETUPTOOLS_USE_DISTUTILS=local
pip install <pkg>
   ```
3. **** (78% success)
   ```
   pyenv install 3.11.9 && pyenv local 3.11.9
pip install <pkg>
   ```

## Dead Ends

- **** — distutils was a stdlib module, never a PyPI package; the install fails. (95% fail)
- **** — No such distribution exists. (95% fail)
- **** — Very old setuptools is incompatible with Python 3.12 in other ways. (80% fail)
