Search code examples
pythonsetuptoolsdistutilsskfuzzypython-3.12

Why did I get an error ModuleNotFoundError: No module named 'distutils'?


I've installed scikit-fuzzy but when I import skfuzzy as fuzz I get an error

ModuleNotFoundError: No module named 'distutils'"

I already tried to pip uninstall distutils and got this output

Note: you may need to restart the kernel to use updated packages.
WARNING: Skipping distutils as it is not installed.

Then I tried to install it again pip install distutils

Note: you may need to restart the kernel to use updated packages.
ERROR: Could not find a version that satisfies the requirement distutils (from versions: none)
ERROR: No matching distribution found for distutils

Where did I go wrong?


This question addresses the problem from the perspective of installing a library. For developing a library, see How can one fully replace distutils, which is deprecated in 3.10?.


Solution

  • Python 3.12 does not come with a stdlib distutils module (changelog), because distutils was deprecated in 3.10 and removed in 3.12. See PEP 632 – Deprecate distutils module.

    You can still use distutils on Python 3.12+ by installing setuptools.

    When that doesn't work, you may need stay on Python < 3.12 until the 3rd-party package (skfuzzy in this case) publishes an updated release for Python 3.12 support.