KiCad 6 tkinter

Hi, I would like to use tkinter in my script, but since KiCad 6, there is an error while loading the tkinter module:

import tkinter
Traceback (most recent call last):
File “”, line 1, in
File “C:\Program Files\KiCad\6.0\bin\Lib\tkinter_init_.py”, line 37, in
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named ‘_tkinter’

Any idea how to solve this? It seems that the tk is installed properly (pip install tk).
Thank you

Kicad6 uses python3 so may be the library is installed for this.

I can’t say if this is the problem you’re having but, sometime during Kicad’s evolution and my using tkinter, I had similar problem and discovered the culpret: Upper/Lower case

Try this:
import Tkinter

I have run into the same problem, although I don’t really need tk. KiCad’s python has access to the wx UI library and I would prefer that.

I found this: python - ImportError: No module named 'Tkinter' - Stack Overflow, and especially https://stackoverflow.com/a/59970646.

It’s possible that the embedded python in the KiCad installation doesn’t have tk.

Actually in KiCad v6 it should be import tkinter because it was changed that way in python. KiCad v6 uses more recent python.

It does but it doesn’t

Python2 → Python3 did rename that package (Tkinter → tkinter) but it does look like it has not been included in Kicad’s packaging for windows.
Linux distributions can have it as kicad uses the system-wide python

Because windows is … windows kicad has to bundle Python, now the py files are there ( KiCad\6.0\bin\Lib\tkinter) but the so/pyd/dll are not. There is a packaging oversight somewhere

  1. additional files being bundled when they shouldn’t be
  2. build of python3 on the windows machine is incomplete.

While kicad does ship with wx, tkinter is quite good for making crude UI very quickly

KiCad6 provides a shell to allow using pip on KiCad’s python install. Look in the start menu and you should see these:
2022-01-12 09_46_18-Window
Use the KiCad Command Prompt to use pip to install packages for KiCad’s python.

The wrinkle is I honestly don’t know how pip handles partial installs as you describe, but at least it is something for @jerabj to try.

1 Like