How to fix “no module named _tkinter” error

The “Tkinter” is a Python library to create GUI for various programs using Python. When dealing with “Tkinter”, an error may arise with the statement “no module named _tkinter”.

This post provides the reasoning and solution to the error “no module named _tkinter”.

How to Resolve the “no module named _tkinter” Problem?

Let’s discuss the possible reasons that invoke the error “no module named _tkinter” and their solutions.

Reason: Tkinter Library not Installed

The prominent cause of this error is that the “Tkinter” library is not installed in the system, and users are trying to import the “Tkinter”. The example code for the “Tkinter” test is shown below:

When the file is executed, the error “no module named tkinter” is displayed as shown below:

Solution: Install the Tkinter Library

The straightforward solution to resolve the error is to install the “Tkinter” library on your Linux. To install this library, run the command as demonstrated below:

For Ubuntu/Debian users:

$ sudo apt install python3-tk

For Fedora users:

$ sudo dnf install python3-tkinter

After installation, you can run the Python code again using the following command and see that the code is now working:

$ python3

That’s it from this guide!


The “no module named _tkinter” problem is invoked when the Tkinter library is not installed on the system, but the Python code is written to utilize the Tkinter library. This issue is resolved by installing the Tkinter module on your system using the “apt” installer in the case of Ubuntu/Debian OS and the “dnf” installer in the case of Fedora OS. This article elaborates on the main reason which causes this error and the solution that will fix it.