[Pythonmac-SIG] Mac OS 10.3.5 and tkinter.

David M.Cooke cookedm at physics.mcmaster.ca
Fri Nov 26 21:56:09 CET 2004


On Nov 26, 2004, at 08:09, Paul Taka wrote:
> Yes, in fact, I've just noticed it before check my mail...
> But I used darwin-7.5.0 instead... (It doesn't matter?)
>
> When I tried to launch the python scripts I wrote under linux, I got 
> an encoding problem. So as it is written on python.org, I added
> # -*- enconding: utf-8 -*-

encoding, I presume

> And replaced #!/usr/bin/python with #!/usr/bin/pythonw
>
> But I still have problems :(
>
> My HelloWorld is like this:

Exactly like the below? It doesn't have a #! or encoding line like you 
were saying.

> ====================================
> from Tkinter import *
>
> fen1=Tk()
>
> tex1= Label(fen1, text="Hello World!", fg='red')
> tex1.pack()
>
> tex2= Label(fen1, text="Bonjour à tous !", fg="blue")
> tex2.pack()
>
> bou1= Button(fen1, text="Quit", command=fen1.destroy)
> bou1.pack()
>
> fen1.mainloop()
> =========================================
>
> And I get:
> syntax error near unexpected token `('
> `fen1=Tk()'
>

How, _exactly_, are you executing this program? That's a bash error 
(the shell):

$ fe=Tk()
-bash: syntax error near unexpected token `('

This suggests to me that the #!/usr/bin/pythonw line is not the _first_ 
line in your script. If you save the above program as helloworld.py 
(with the #! and encoding line), and execute it at the prompt:

$ pythonw helloworld.py

If that works, you can make your script executable and run it directly:

$ chmod +x helloworld.py
$ ./helloworld.py
-- 
|>|\/|<
/------------------------------------------------------------------\
|David M. Cooke              http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca



More information about the Pythonmac-SIG mailing list