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:

Bring Your PyQt/PySide Application to Market — Specialized launch support for scientific and engineering software built using Python & Qt.

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.

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 ]]
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 is the creator of Python GUIs, and has been developing Python/Qt applications for the past 12+ years. He has written a number of popular Python books and provides Python software development & consulting for teams and startups.