Skip to content
Advertisement

ImportError: No module named ‘Tkinter’

For some reason, I can’t use the Tkinter or tkinter module. After running the following command in the python shell

JavaScript

or

JavaScript

I got this error

ModuleNotFoundError: No module named ‘Tkinter’

or

ModuleNotFoundError: No module named ‘tkinter’

What could be the reason for and how can we solve it?

Advertisement

Answer

You probably need to install it using something similar to the following:

  • For Ubuntu or other distros with Apt:

    JavaScript
  • For Fedora:

    JavaScript

You can also mention a Python version number like this:

  • JavaScript
  • JavaScript

Finally, import tkinter (for Python 3) or Tkinter (for Python 2), or choose at runtime based on the version number of the Python interpreter (for compatibility with both):

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement