Installing tkinter on ubuntu 14.04
Try writing the following in the terminal:
sudo apt-get install python-tk
Don't forget to actually import Tkinter module at the beginning of your program:
import Tkinter
If you're using Python 3
then you must install as follows:
sudo apt-get updatesudo apt-get install python3-tk
Tkinter for Python 2
(python-tk
) is different from Python 3
's (python3-tk
).
To get this to work with pyenv
on Ubuntu 16.04, I had to:
$ sudo apt-get install python-tk python3-tk tk-dev
Then install the version of Python I wanted via pyenv
:
$ pyenv install 3.6.2
Then I could import tkinter just fine:
import tkinter