[Solved] 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

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?

Enquirer: RasmusGP


Solution #1:

You probably need to install it using one of (or something similar to) the following:

sudo apt-get install python3-tk 

You can also mention version number like this
sudo apt-get install python3.7-tk for python 3.7.

sudo dnf install python3-tkinter

Why don’t you try this and let me know if it worked:

    # for Python2
    from Tkinter import *   ## notice capitalized T in Tkinter 
except ImportError:
    # for Python3
    from tkinter import *   ## notice lowercase 't' in tkinter here

Here is the reference link and here are the docs

Better to check versions as suggested here:

if sys.version_info[0] == 3:
    # for Python3
    from tkinter import *   ## notice lowercase 't' in tkinter here
    # for Python2
    from Tkinter import *   ## notice capitalized T in Tkinter

Or you will get an error ImportError: No module named tkinter

Just to make this answer more generic I borrowed the following from Devendra Bhat‘s comment:

On Fedora please use either of the following commands

sudo dnf install python3-tkinter-3.6.6-1.fc28.x86_64


sudo dnf install python3-tkinter
Respondent: d-coder

Solution #2:

As you are using Python 3, the module has been renamed to tkinter, as stated in the documentation:

Note Tkinter has been renamed to tkinter in Python 3. The 2to3 tool
will automatically adapt imports when converting your sources to
Python 3.

Respondent: Burhan Khalid

Solution #3:

For windows 10, it is important to check in the Python install the optional feature “tcl/tk and IDLE”. Otherwise you get a ModuleNotFoundError: No module named ‘tkinter’. In my case, it was not possible to install tkinter after the Python install with something like “pip install tkinter”

Respondent: Andi Schroff

Solution #4:

You might need to install for your specific version, I have known cases where this was needed when I was using many versions of python and one version in a virtualenv using for example python 3.7 was not importing tkinter I would have to install it for that version specifically.

For example

sudo apt-get install python3.7-tk 

No idea why – but this has occured.

Respondent: deMangler

Solution #5:

For Windows 10 using either VSCode or PyCharm with Python 3.7.4 – make sure Tk is ticked in the install. I tried import tkinter as xyz with upper/lower t and k‘s and all variants without luck.

What works is:

import tkinter
import _tkinter

An example in action:

import tkinter
import _tkinter

HEIGHT = 700
WIDTH = 800

root = tkinter.Tk()

canvas = tkinter.Canvas(root, height = HEIGHT, width=WIDTH)

frame = tkinter.Frame(root, bg='red')

Respondent: Jeremy Thompson

Solution #6:

check the python version you have installed by using command python --version

check for the Tk module installed correctly from following code

sudo apt-get install python3-tk 

Check if you are using open-source OS then

check the tkinter module in the following path
change the path accordingly your system

Respondent: Devaliya Pratik

Solution #7:

Make sure that when you are running your python code that it is in the python3 context. I had the same issue and all I had to do was input the command as:

sudo python3


sudo python

the latter code is incorrect because tkinter is apparently unnavailable in python1 or python2.

Respondent: Owen Preece

Solution #8:

On CentOS7, to get this working with Python2, I had to do:

yum -y install tkinter

Noting this here because I thought that there would be a pip package, but instead, one needs to actually install an rpm.

Solution #9:

You just need to install it and import them your project like that :

this code import to command line :

sudo apt-get install python3-tk 

after import tkinter your project :

from tkinter import *
Respondent: Jafar Choupan

Solution #10:

Check apt for tasks, it may be marked for removed

sudo apt autoremove

Then check and install needed

Respondent: Sergey Shamanayev

Solution #11:

if it doesnot work in pycharm you can add the module in the project interpreter by searching in +button python-tkinter and download it.

Respondent: santosh ghimire

Solution #12:

Tkinter should come with the latest Python, I don’t think it comes with Python2. I had the same problem but once. I upgraded to Python 3.8 Tkinter was installed.

Respondent: Eloni

Solution #13:

use below.

from tkinter import *
Respondent: sameer_nubia

Solution #14:

tkinter comes with python… uninstall python, reinstall it, you’re done

Respondent: Giovanni G. PY

Solution #15:

——— WORKED ON PYTHON 2.7————

Install all below packages

sudo apt-get install git
sudo apt-get install python-tk
sudo apt-get install python-pip
sudo apt install picolisp
sudo -H pip2 install --upgrade pip
sudo pip install -I pillow
sudo apt-get install python-imaging-tk
sudo apt-get install python-tk
Respondent: RAHUL

Solution #16:

The best way is from tkinter import *

Respondent: Bogdan Prisacaru

Solution #17:

Firstly you should test your python idle to see if you have tkinter:

import tkinter


Trying typing it, copy paste doesn’t work.

So after 20 hours of trying every way that recommended on those websites figured out that you can’t use “” or any other file name that contains “”. If you have the same problem, just change the file name.

Respondent: Mehmet Nergiz

Solution #18:

You should try this :

pip install tkinter

I hope this would solve the issue.

Respondent: Tahil Bansal

Solution #19:

I think you should try this:

from tkinter import *


from Tkinter import *

It really depends on what type of computer you use, or what version of python you have.

Respondent: Ender

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy