Install Tkinter on Ubuntu Linux

Install Tkinter on Ubuntu and other Debian-based Linux distributions
Heads up! You've already completed this tutorial.

Before you start the Tkinter tutorial, you need a working installation on your system. This short tutorial provides the steps to install Tkinter on Ubuntu Linux.

This guide is also available for macOS. On Windows, Tkinter is installed by default with Python.

Install Tkinter on Ubuntu Using apt

In Ubuntu, you'll note that the Tkinter library isn't installed in the default distribution. We can install Tkinter either from the command line with the apt command or via the Software Center. The package we are looking for is python3-tk.

Best practices in Python recommend using virtual environments instead of installing packages directly into the system Python installation. The command shown below installs Tkinter in your system Python.

To install Tkinter from the command line, execute the following commands:

bash
$ sudo apt update 
$ sudo apt install python3-tk

The first command updates the package information from all sources of software we are using in our Ubutu system. The second command downloads and installs Tkinter.

After the installation is finished, you can start a Python interactive session and import the tkinter package as shown below:

The complete guide to packaging Python GUI applications with PyInstaller.
[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]

python
>>> import tkinter as tk

Now that you've completed the installation in your Linux system, you can start creating Python GUI applications with Tkinter.

Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.

More info Get the book

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

Install Tkinter on Ubuntu Linux was written by Martin Fitzpatrick with contributions from Leo Well .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular https://www.martinfitzpatrick.com/browse/books/ on the subject.