python 2.7 - no module named tkinter

i am on mac os x 10.8, using the integrated python 2.7. i try to learn about tkinter with tutorials like this for python 2.7 (explicitly not 3) they propose the following code:

from tkinter import *
import tkinter.messagebox

however, this brings up the error:

ImportError: No module named tkinter

using import.Tkinter with a capital t seems to work, but further commands like

import Tkinter.messagebox

don't (neither does tkinter.messagebox). I've had this problem with lots of tutorials. what's the thing with the capital / non-capital "T", and how do i get my python to work like it does in the tutorials? Thanks in advance!


In Tkinter (uppercase) you do not have messagebox. You can use Tkinter.Message or import tkMessageBox

This code is an example taken from this tutorial:

import Tkinter
import tkMessageBox

top = Tkinter.Tk()
def hello():
   tkMessageBox.showinfo("Say Hello", "Hello World")

B1 = Tkinter.Button(top, text = "Say Hello", command = hello)


Your example code refers to a python installation >= py3.0. In Python 3.x the old good Tkinter has been renamed tkinter.

Tkinter (capitalized) refers to versions <3.0.

tkinter (all lowecase) refers to versions ≥3.0.


For python 2.7 it is Tkinter, however in 3.3.5 it is tkinter.

For python 2.7 use Cap Letters Tkinter but for >3.0 use small letter tkinter

Need Your Help

Library for calculating gamma index? (Preferrably in R or Python, but any language is OK)

python r matlab physics scientific-computing

In physics--especially medical physics--the gamma index is a criterion for comparing data from two particle detectors. More abstractly, the gamma index takes two 2D arrays (let's say array1 and arr...

getJSON not working when not using twitter api

jquery ajax json twitter jsonp

I just started using getJson today and am a major novice when it comes to json/jquery/ajax stuff. I have been using: