“ImportError: No module named tkinter” when using Pmw

后端 未结 5 815
傲寒
傲寒 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:42

    Another workaround would be the following:

    try:
        import tkinter
    except:
        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.

提交回复
热议问题