Install and Test Tkinter/tkinter in Ubuntu-Linux, Debian or Linux Mint
Posted: Mon Jan 22, 2018 11:49 am
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:
The command above will install python 2 in your system, to install python 3, run the command below:
You can now install Tkinter, depending on the version of Python you have. To install Tkinter for python 2, execute in the command line:
and
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.,
If everything works as expected, now, check that you can create an empty window using Tkinter:
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
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
Code: Select all
sudo apt-get install python3
Code: Select all
sudo apt-get install python-tk
Code: Select all
sudo apt-get install python3-tk
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
Code: Select all
Tkinter.Tk()
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