How to get tkinter working with Ubuntu's default Python 2.7 install? How to get tkinter working with Ubuntu's default Python 2.7 install? tkinter tkinter

How to get tkinter working with Ubuntu's default Python 2.7 install?


I figured it out after way too much time spent on this problem, so hopefully I can save someone else the hassle.

I found this old bug report deemed invalid that mentioned the exact problem I was having, I had Tkinter.py, but it couldn't find the module _tkinter: http://bugs.python.org/issue8555

I installed the tk-dev package with apt-get, and rebuilt Python using ./configure, make, and make install in the Python2.7.3 directory. And now my Python2.7 can import Tkinter, yay!

I'm a little miffed that the tk-dev package isn't mentioned at all in the Python installation documentation.... below is another helpful resource on missing modules in Python if, like me, someone should discover they are missing more than _tkinter.

Building Python and more on missing modules


I had same issue with python3.4 (ImportError: No module named '_tkinter')

sudo apt-get install tk-dev

got to python source directory

./configuremakesudo make install


The following solved the issue for me on Linux Mint 16:

sudo apt-get install tk-dev python-tk 

I use virtualenv but did not want to compile python, in order to make the python support tk, python-tk should be installed.