How to fix Python ModuleNotFoundError: No module named ‘tkinter’ in Linux?

How to fix Python ModuleNotFoundError: No module named ‘tkinter’ in Linux?


When you execute your first GUI program or import an existing GUI program in Python you might get ModuleNotFoundError: No module named ‘tkinter’ or ‘Tkinter’ this arises because the Tkinter module is not installed with the Python set up on your system.

The error will look something like this –

In this article we will discuss why this error arises and how can you fix this.

What is Tkinter?

Tkinter is Python’s standard graphical user interface (GUI) package. It provides functionalities to create GUI applications. Generally, it gets installed with the Python package.

The package was available in Python 2 with the name ‘Tkinter’ now it is renamed in Python 3 to ‘tkinter’ (in small case).

How to check if the Tkinter package is installed on your system or not?

You can use the following command to check if tkinter module is installed on your Linux system or not. For using this you should have python3 installed on your system.

python3 -m tkinter

You will see the following output if it is not installed –

If you want to check it for Python 2 then you need to use separate command.

How to install the Tkinter module on your system?

Now if Tkinter module is not installed on your system then use the following command in your Linux terminal.

sudo apt install python3-tk -y

When it asks for your password enter it. This will start the installation process on your Linux system. You can check again that if tkinter is now installed or not with the given command –

python3 -m tkinter

This will open a new window like given in the image below.


The error should be fixed now, Now you should be able to execute your GUI program on your system.

If still this not works for you then write us in the comments below.

Previous How to Compile and Run C Program on a Linux Terminal
Next Python List Comprehension

About author

You might also like

Linux Topics 0 Comments

How To Switch Users In A Linux Or Unix Terminal?

This post was last updated on August 1st, 2020 at 02:42 pmLinux/Unix is a multi-user operating system that means more than one user can use system resources simultaneously. In order

Linux Topics 1Comments

How to Fix Windows And Linux Showing Different Time In A Dual Boot System

This post was last updated on August 3rd, 2020 at 02:34 pmThere are many users who use a dual boot computer. Dual-booting Linux with Windows operating system has various advantages

Linux Topics 0 Comments

How To Kill A Running Process In Linux/Unix?

This post was last updated on August 1st, 2020 at 12:44 pmIn Linux, a process is an instance of a program that is running on a computer. When a program


No Comments Yet!

You can be first to comment this post!

Leave a Reply