Install and Test Tkinter/tkinter in Ubuntu-Linux, Debian or Linux Mint

Post Reply
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5161
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#1

Tkinter is a graphical user interface (GUI) module for Python. It can be used to make GUI based applications in Python. Tkinter provides several GUI widgets such as buttons, menu, canvas, text, frame, label and so on, that are used to develop various desktop applications. Though Tkinter is very popular, there are also alternatives to Tkinter, which include, pyQt and wxPython.

If you are running some Python application that requires Tkinter, you can get an error message "ImportError: No module named _tkinter, please install the python-tk package"

This error message means Tkinter module is not installed in your system.

To install Tkinter, you need to have an appropriate version of Python installed in your system. Open the Terminal and type "python" to check which version of Python your system is running.

If you don't have python, then install it:

Code: Select all

sudo apt-get install python
The command above will install python 2 in your system, to install python 3, run the command below:

Code: Select all

sudo apt-get install python3
You can now install Tkinter, depending on the version of Python you have. To install Tkinter for python 2, execute in the command line:

Code: Select all

sudo apt-get install python-tk
and

Code: Select all

sudo apt-get install python3-tk
for python 3.

To check whether Tkinter is installed and works correctly for python 2, type "python" in the Terminal and then import Tkinter, i.e.,

Code: Select all

$python

>>>import Tkinter
If everything works as expected, now, check that you can create an empty window using Tkinter:

Code: Select all

Tkinter.Tk()
For python 3, follow the same steps as for python 2 to check that tkinter is installed and works fine. Note that in python 3 , Tkinter is named "tkinter".

See how to install Tkinter without root privileges and how to install Tkinter on other versions of Linux:

https://stackoverflow.com/questions/478 ... for-python
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Linux and Unix Based Operating Systems”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests