Tkinter unavailable

Hi All,
I have this little problem with tkinter:

$ python3
Python 3.10.11 (main, Dec 14 2024, 05:01:01) [GCC 11.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import tkinter
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python3.10/tkinter/init.py”, line 37, in
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named ‘_tkinter’

The tkinter folder is where I would expect to find it, as indicated above.
How can I ‘configure’ my Python for tkinter?

thanks
Gary B

How did you install Python? If it’s provided by a distro, you need to install Tcl/Tk or a specific python3-tk package. If you compiled it yourself, you need to have Tcl/Tk installed at compile time.

Look like you built your own python.
You need to install the tcl/tk development package for your system.
Then when you run ./configure the tcl/tk should be detected and python should build what you need.

I assume that you are using a linux distribution that does package the version of python you want to use. Is that correct?
Which distribution are you using?

Thanks for reply, Barry. I am using Mint 21.2. I just ran make again and got the following:

$ make
CC=‘gcc’ LDSHARED=‘gcc -shared ’ OPT=’-DNDEBUG -g -fwrapv -O3 -Wall’ _TCLTK_INCLUDES=‘’ _TCLTK_LIBS=‘’ ./python -E ./setup.py build
running build
running build_ext
INFO: Can’t locate Tcl/Tk libs and/or headers

The necessary bits to build these optional modules were not found:
_dbm _gdbm _lzma
_tkinter _uuid
To find the necessary bits, look in setup.py in detect_modules() for the module’s name.

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc pwd time

running build_scripts
copying and adjusting /home/gary/Downloads/Python-3.10.11/Tools/scripts/pydoc3 → build/scripts-3.10
copying and adjusting /home/gary/Downloads/Python-3.10.11/Tools/scripts/idle3 → build/scripts-3.10
copying and adjusting /home/gary/Downloads/Python-3.10.11/Tools/scripts/2to3 → build/scripts-3.10
changing mode of build/scripts-3.10/pydoc3 from 664 to 775
changing mode of build/scripts-3.10/idle3 from 664 to 775
changing mode of build/scripts-3.10/2to3 from 664 to 775
renaming build/scripts-3.10/pydoc3 to build/scripts-3.10/pydoc3.10
renaming build/scripts-3.10/idle3 to build/scripts-3.10/idle3.10
renaming build/scripts-3.10/2to3 to build/scripts-3.10/2to3-3.10

Can you tell from the last output, what decorators I should have on ./configure?

thanks.
Gary B

I do not know Mint, but I’m sure they provide packages for the libraries you need. What version of python is incluide with 21.2?
It seems from this Installing and Configuring Python on Linux Mint | FOSS Linux that 3.10 is available as packages.
Maybe you need the Mint 22 to get 3.10?

If you do want to build python yourself you should first check the output of ./configure to see what libraries it fails to find. Then install them from the Mint packages. If you do not know how to do this you will need to ask Mint community for help.

Barry, right after posting the 2nd post I thought of your statement that “Looks like you built your own python” and that caused a brain burp. “Hey, I can download this on synaptic.” Yes true, and the same version was even there; however, it was a couple minor revs earlier than the one I had installed so it didn’t change anything about the faulty install. Also, I saw in the -make- comments that some alteration had been done to module: time. Since the python install, time has been wacko, exactly 1 < x < 6 hours wrong (xfce4) and no better after several attempts to fix.

So considering that that might be a complicated investigation/correction, I decided to burn the whole distro to the ground and start over.

That done, things are going smoother (python3-tk install required though) and I apologize for bothering you.

1 Like