Tkinter: problems running as a script.

Tamito Kajiyama kajiyama at grad.sccs.chukyo-u.ac.jp
Wed Jun 28 13:50:25 EDT 2000


Aaron Ginn <aaron.ginn at motorola.com> writes:
| 
| I'm unable to run a simple "Hello, world" python script, but I
| can run the script if I paste the lines one at a time into the
| python interpreter.
(snip)
| coronado <213> ~/bin/Tkinter.py
| Traceback (innermost last):
|   File "/home/ginn/bin/Tkinter.py", line 2, in ?
|     from Tkinter import *
|   File "/home/ginn/bin/Tkinter.py", line 4, in ?
|     root = Tk()
| NameError: Tk
(snip)
| What am I doing wrong here?

You need to change the filename of the script other than those
of Python modules including Tkinter.py.

Python adds to the module search path (i.e. sys.path) the
directory where the executable script lives.  In this case, 
~/bin is considered as a directory holding Python modules.
That's why your script imports itself instead of the standard
Tkinter module.

Regards,

--
KAJIYAMA, Tamito <kajiyama at grad.sccs.chukyo-u.ac.jp>



More information about the Python-list mailing list