"ImportError: No module named tkinter" when using Pmw "ImportError: No module named tkinter" when using Pmw tkinter tkinter

"ImportError: No module named tkinter" when using Pmw


Maybe I can help you on how to remove the error.

here are two thoughts:

1) you use python 2.xx and have installed the python 3 pwm module (Tkinter was renamed to tkinter from Python 2 to 3)

2) you do the following before the import and hope it helps:

#import tkinter#Traceback (most recent call last):#  File "<pyshell#11>", line 1, in <module>#    import tkinter#ImportError: No module named tkinterimport sys, Tkintersys.modules['tkinter'] = Tkinter # put the module where python looks first for modules#import tkinter # now works!


Another workaround would be the following:

try:    import tkinterexcept:    import Tkinter as tkinter

This way you would always have the module tkinter available and depending on the Python version your program loads tkinter or Tkinter.


I was facing the same problem with matplotlib.pyplot (python 2.7+) in my CentOs. I solved the problem by just installing the tkinter. sudo yum install tkinter. Hope this can help you.