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

0/5 Votes: 0
Report this app


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.

2 comments on "How to fix Python ModuleNotFoundError: No module named ‘tkinter’ in Linux?"

  1. Shidah says:

    Hi, thank you for sharing the solution to this issue. I faced another ModuleNotFoundError after I entered python3 -m tkinter. The message is:

    Traceback (most recent call last):
    File “/usr/lib/python3.7/”, line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
    File “/usr/lib/python3.7/”, line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
    File “/usr/lib/python3.7/”, line 109, in _get_module_details
    File “/usr/lib/python3.7/tkinter/”, line 36, in
    import _tkinter # If this fails your Python may not be configured for Tk
    ModuleNotFoundError: No module named ‘_tkinter’

    By the way, I am installing the module on the Xilinx Kria KV260 Petalinux terminal. I hope you can give me some advice on how to solve this issue. Thank you, really appreciate it.

Leave a Reply

Your email address will not be published. Required fields are marked *