Before you start the Tkinter tutorial you will need to have a working installation of PyQt5 on your system. If you don't have either set up yet, the following steps will guide you through how to do this on Linux.
This guide is also available for macOS. On Windows, Tkinter is installed by default with Python.
Install Tkinter via apt
Packages for Tkinter are available in the repositories of most distributions.
In Ubuntu you can install either from the command line or via "Software Center". The package you are looking for is named python3-tk
.
You can also install these from the command line as follows --
sudo apt install python3-tk
After install is finished, you should be able to run python3
(or python
) and import tkinter
without errors.
Python 3.7.6
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>>
You can now start creating Python GUI applications with Tkinter.