Python says there is no module named tkinter, but tkinter is part of the standard library — how can it be missing?
I am trying to run a small program with a graphical window and it fails on the import with a message that there is no module named tkinter.
Everything I read says tkinter is part of the standard library, which is exactly why I chose it rather than installing something. So I do not understand how it can be absent.
Installing it with the package installer does not work either — either nothing sensible is found, or something installs and the import still fails.
What is actually going on, and how do I fix it properly rather than switching to a different library?
@django_dependable · 4h ago
The version-manager case deserves emphasis because it produces the most confusing version of this.
It is silent. You install a Python version, it succeeds, everything looks correct, and the only symptom appears later when you import one specific module. The same thing happens with a couple of other standard library modules that wrap system libraries — the compression and database ones are the usual companions.
So if tkinter is missing on a version-managed interpreter, check those too before you rebuild, and install all the development packages in one go. Otherwise you rebuild for tkinter today and rebuild again next week for something else.
Most of these version managers publish a list of the system packages to install first for exactly this reason. Reading it once saves several rebuilds.
Reply
Report