[Tutor] Modules

Alan Gauld alan.gauld at btinternet.com
Wed Mar 27 22:09:26 CET 2013


On 27/03/13 19:34, Cor Heisterkamp wrote:

> My problem starts with the chapter "Introduction to Modules".
> The first line in the program is:
>       from tkinter import *
> and here I'm getting an error:
>       ImportError: No module named tkinter

Thats an unfortunate exampole the author has chosen.

Tkinter is an unusual module in that it requires support for Tcl/Tk to 
be compiled into the interpreter. This is not always the case.

So there are 3 possible causes of the error:

1) Your python does not have support for Tcl/Tk built in.
Which version of Python and which OS are you using? If your version does 
not support Tcl you need to either build a version from source or find a 
copy for your OS with Tkinter support. The default downloads for MacOS, 
Windows and most Linuxes have it but the OS installed versions often don't.

2) The tutor is aimed at Python v3 but you are using v2
Which version of Python are you running? What does it say
when you start the Python interpreter >>> prompt?

3) The tutor and you are both on V2 but you mistyped (or it has a typo) 
that says tkinter when it should say Tkinter.

Try typing

import Tkinter


HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list