Fix Python distutils ModuleNotFoundError | Generated by AI
The error occurs because the distutils
module, part of Python’s standard library, is missing in your environment. This is common in minimal Python installations. Here’s how to fix it:
Solution:
- Install Python development tools (includes
distutils
):sudo apt update && sudo apt install python3-distutils python3-dev
- Reinstall
setuptools
(to ensure proper functionality):pip install --upgrade --force-reinstall setuptools
- Retry installing your requirements:
pip install -r requirements.local.txt
Why this works:
python3-distutils
provides the missingdistutils
module.python3-dev
includes necessary headers/building tools.- Reinstalling
setuptools
resolves any lingering configuration issues.
If you’re in a virtual environment, recreate it after installing the system packages to ensure the environment has access to the required modules.