ModuleNotFoundError: No module named ‘Tkinter’

This dev tip is brought to you by the developer of MoneyPhone: Personal Expense Tracking for Android and iOS. Consistently spend less than you earn each month and get your finances under control when you start monitoring your expenses with MoneyPhone!

Fret not dear pythoneer, all you need to do to fix this is change Tkinter to tkinter as the name of the module has changed in Python 3. Whoops! Also, make sure to change

print "stuff"
to
print("stuff")
and all will be well!

from tkinter import *
class Application(Frame):
def say_hi(self):
print("hi there, everyone!")
def createWidgets(self):
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.QUIT.pack({"side": "left"})
self.hi_there = Button(self)
self.hi_there["text"] = "Hello",
self.hi_there["command"] = self.say_hi
self.hi_there.pack({"side": "left"})
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()
view raw hello_tkinter.py hosted with ❤ by GitHub
 

topherPedersen