FAQ
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100819/683b1134/attachment.html>

Search Discussions

  • Sergey Smirnov at Aug 19, 2010 at 12:53 pm
    *when I actually *

    *type it I get an error msg*

    Did you type python commands in a bash console? In case you did, you should
    run python interactive console instead. Just type python in terminal window
    and than you'll be able interactively run statements.

    If you have your script saved in a file, for instance, script.py, to run it
    on your Mac you should type:
    $ python script.py

    It would be easier to understand you if you'll post errors messages here.
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20100819/ce4e95df/attachment.html>
  • Sergey Smirnov at Aug 19, 2010 at 2:15 pm
    I see.
    Your script begins with a string:

    $ python test.py

    It's not a valid python code. Maybe you just copied this text to your script
    accidentally. Try to delete the first string. Can you send a few first
    strings of your script?

    On Thu, Aug 19, 2010 at 17:05, Agida Kerimova wrote:

    this is what it looks like

    On Thu, Aug 19, 2010 at 7:01 PM, Agida Kerimova wrote:

    Hi, I don't know how to work in a non bash console... I typed python in a
    terminal window and all but it didn't work...





    On Thu, Aug 19, 2010 at 5:53 PM, Sergey Smirnov wrote:

    *when I actually *

    *type it I get an error msg*

    Did you type python commands in a bash console? In case you did, you
    should run python interactive console instead. Just type python in terminal
    window and than you'll be able interactively run statements.

    If you have your script saved in a file, for instance, script.py, to run
    it on your Mac you should type:
    $ python script.py

    It would be easier to understand you if you'll post errors messages here.

    --
    http://mail.python.org/mailman/listinfo/python-list

    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20100819/a5db1e4f/attachment.html>
  • Benjamin Kaplan at Aug 19, 2010 at 2:08 pm

    On Thu, Aug 19, 2010 at 8:22 AM, Agida Kerimova 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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedAug 19, '10 at 12:22p
activeAug 19, '10 at 2:15p
posts4
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase