58

When I try to import customtkinter in Python 3.12, I get the following error:

 File "c:\Users\judel\OneDrive\Documents\Python\main.py", line 1, in <module> import customtkinter as ttk File "C:\Users\judel\AppData\Local\Programs\Python\Python312\Lib\site-packages\customtkinter\__init__.py", line 10, in <module> from .windows.widgets.appearance_mode import AppearanceModeTracker File "C:\Users\judel\AppData\Local\Programs\Python\Python312\Lib\site-packages\customtkinter\windows\__init__.py", line 1, in <module> from .ctk_tk import CTk File "C:\Users\judel\AppData\Local\Programs\Python\Python312\Lib\site-packages\customtkinter\windows\ctk_tk.py", line 2, in <module> from distutils.version import StrictVersion as Version ModuleNotFoundError: No module named 'distutils' 

Why is this happening? Why can't a module from the standard library be found?

1
  • 1
    Please provide enough code so others can better understand or reproduce the problem. Commented Oct 7, 2023 at 0:43

1 Answer 1

105

It appears that customtkinter uses distutils from the standard library.

Unfortunately, you're using the newly released Python 3.12, which removed distutils after it being deprecated since Python 3.10. See PEP 632 Deprecate distutils module and gh-92584 for more details about its removal.

If you want to use that distribution, you'll need to either

  1. install setuptools, which now also provides distutils, or
  2. sideload distutils from a third party source (e.g. a system package, like apt install python3-distutils), or
  3. downgrade to an older version of Python (3.11 or older), or
  4. wait for its maintainer to update it to support Python 3.12.
Sign up to request clarification or add additional context in comments.

8 Comments

In my case setuptools-65.7.0 has been installed but it still raises the exception. It gets fixed after updating it to 68.2.2 by python -m pip install --upgrade setuptools.
worked to fix gradio package problems: pip install setuptools
"pip install setuptools" still raises the exception
Installing setuptools fixed it for me when I wanted to test something with a very old version of Pandas (1.2.0). Thank you.
2024. Installing setuptools fixed it also for me for an old project that was on Py 3.7.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.