Tuesday, October 14, 2014

Python 2.7 - No module named Tkinter

If you have one Python program that needs Tkinter module, and you have “Tkinter” module imported as follows:
import Tkinter
from Tkinter import *

If you are still getting “ImportError: No module named Tkinter”:
Traceback (most recent call last):
  File "paddleball.py", line 1, in <module>
    import Tkinter
ImportError: No module named Tkinter

Probably you don’t have “Tkinter” installed.

To install “Tkinter” module, what you need to do is:
# yum install tkinter

# apt-get install python-tk

Then run your program again, you should be good to go.

Note: In Python 3.x “Tkinter” has been renamed “tkinter”.

No comments: