How do I make python test.py work without a syntax error msg?

Benjamin Kaplan benjamin.kaplan at case.edu
Thu Aug 19 10:08:28 EDT 2010


On Thu, Aug 19, 2010 at 8:22 AM, Agida Kerimova <agidak at gmail.com> wrote:
> I am new to programming/python and have been having some difficulties
> getting started. I can't seem to run scripts without a syntax error msg.
> When I drag the file to the IDLE launcher or run the module it works, but
> when I actually type it I get an error msg. I've been told  that the path to
> python executable is missing or that i have to specify the path but im not
> sure how to do this. I read some articles online but they are not very
> clear. A lot of the articles talk about doing this on windows but i have a
> mac. Also when I type python at the prompt it starts. Can someone please let
> me know what Im doing wrong or give me some advice?
> Thanks!
> --


Are you trying to run ./test.py? If so, make sure you use a shebang
line. The Unix shell doesn't care about those silly little things
called file extensions- that's just part of the file name, after all.
Any executed file will use the shell (bash on OS X) unless you specify
otherwise. Add the following line to the top of the file:
#!/usr/bin/env python

Or, just call the Python interpreter directly
python test.py



More information about the Python-list mailing list