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 and other Debian-based Linux distributions.

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

Install Tkinter on Ubuntu Using apt

In Ubuntu, Tkinter isn't included in the default Python installation. You can install Tkinter either from the command line with the apt package manager or via the Software Center. The package you need 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:

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

The first command updates the package information from all configured software sources on your Ubuntu system. The second command downloads and installs the Tkinter package for Python 3.

This same approach works on other Debian-based distributions such as Linux Mint and Pop!_OS, since they also use the apt package manager.

Verify the Tkinter Installation

After the installation is finished, you can verify that Tkinter is correctly installed by starting a Python interactive session and importing the tkinter package:

python
>>> import tkinter as tk

If the import completes without errors, Tkinter is ready to use. You can also check the installed version:

1:1 Coaching & Tutoring for your Python GUIs project
Martin Fitzpatrick Python GUIs Coaching & Training
60 mins ($195) Book Now

1:1 Python GUIs Coaching & Training

Comprehensive code reviewBugfixes & improvements • Maintainability advice and architecture improvements • Design and usability assessment • Suggestions and tips to expand your knowledgePackaging and distribution help for Windows, Mac & Linux • Find out more.

python
>>> tk.TkVersion

Now that you've completed the Tkinter installation on 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.

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 Python books on the subject.