Fix Python – ImportError: No module named ‘Tkinter’


Asked By – RasmusGP

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

import Tkinter


import tkinter

I got this error

ModuleNotFoundError: No module named ‘Tkinter’


ModuleNotFoundError: No module named ‘tkinter’

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

Now we will see solution for issue: ImportError: No module named ‘Tkinter’


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

  • For Ubuntu or other distros with Apt:

    sudo apt-get install python3-tk
  • For Fedora:

    sudo dnf install python3-tkinter

You can also mention a Python version number like this:

  • sudo apt-get install python3.7-tk
  • sudo dnf install python3-tkinter-3.6.6-1.fc28.x86_64

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):

import sys
if sys.version_info[0] == 3:
    import tkinter as tk
    import Tkinter as tk

This question is answered By – d-coder

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0