“ImportError: No module named tkinter” when using Pmw

后端 未结 5 821
傲寒
傲寒 2020-12-20 21:13

Here\'s my problem: I\'m running the code in this example. I have Python 2.7 and 3 installed on my RaspberryPi but I have checked and double-checked, and I am running the c

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-20 21:51

    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 "", line 1, in 
    #    import tkinter
    #ImportError: No module named tkinter
    
    import sys, Tkinter
    sys.modules['tkinter'] = Tkinter # put the module where python looks first for modules
    #import tkinter # now works!
    

提交回复
热议问题