Page 1 of 1

Python/Tkinter: Examples not working

Posted: Sat Jun 30, 2007 12:07 pm
by ^rooker
[PROBLEM]
I was trying to go through the tutorial for Tkinter at Pythonware

The hello world example gave me the following, strange errormessage:
from: can't read /var/mail/Tkinter
./ex1.py: line 5: syntax error near unexpected token `('
./ex1.py: line 5: `root = Tk()'
[SOLUTION]
The reason for the error is that the examples don't start with the linux typical "shebang!" - e.g. "#!/usr/bin/python", but with "# file: xxx".

Change the first line to the correct shebang for your environment and everything's fine.

Examples:
"#!/usr/bin/python" for Debian based distros (e.g. Ubuntu)
"#!/usr/bin/env python" to be less path dependent