Python launcher problem in Mac OS X 10.5

Discussion in 'Mac Programming' started by Nicolaius, Jan 4, 2009.

  1. Nicolaius macrumors newbie

    Joined:
    Jan 4, 2009
    #1
    Hi, everyone. I hate to be "that guy" whose first post is some idiotic question, and normally I would just lurk around google until I found someone else who asked the same thing with the question answered, but I guess my eyes weren't as sharp this time around.

    I have a very basic knowledge of C++, but as of today I began learning some python.

    Anyway, my problem is just straight up running .py files. I've saved some very basic code, and when I open it, the python launcher and the terminal both launch on the dock. The python launcher does nothing at all but just look pretty with the light under it on the dock, and terminal just opens normally as if I just...well, straight up opened terminal. Either way, it's not doing what I wanted. I considered the option that I didn't properly code the app so that it would pause the console, but even after I did that...same problem.

    Of course, any help would be greatly appreciated.

    Thanks a lot,
    Nico
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Open the Terminal. Navigate to where you saved the .py file and type python filename.py that should run your program for you.
     
  3. Nicolaius thread starter macrumors newbie

    Joined:
    Jan 4, 2009
    #3
    I also tried that. But whenever I do I get an error message from terminal. Here's all of the text:

    Last login: Sun Jan 4 15:51:30 on ttys000
    my-macbook:~ Nicola$ python game_over.py
    /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python: can't open file 'game_over.py': [Errno 2] No such file or directory
    my-macbook:~ Nicola$ python
    Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
    [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> /Users/Nicola/Documents/Python\ Source_Examples/chapter02/game_over2.py
    File "<stdin>", line 1
    /Users/Nicola/Documents/Python\ Source_Examples/chapter02/game_over2.py
    ^
    SyntaxError: invalid syntax
    >>>
     
  4. ReadyEddy macrumors newbie

    Joined:
    Jan 4, 2009
    #4
    In terminal
    Either
    navigate to the location of the python file i.e.
    cd /Users/Nicola/Documents/Python\ Source_Examples/chapter02
    then launch python i.e.
    python game_over2.py
    Or quote the full path i.e.
    python /Users/Nicola/Documents/Python\ Source_Examples/chapter02/game_over2.py

    Some comments that may help.
    If you installed python yourself without realizing that Python 2.5 is already installed on your system, its best to work out where the second has been put on your system and consider whether you want to keep it on your system.
    Do not delete the system python under any circumstances.
    You are going to have to learn about the command line i.e. unix as well as python.
    Good Luck
     
  5. Nicolaius thread starter macrumors newbie

    Joined:
    Jan 4, 2009
    #5
    Thank you very much, guys. But um...I'm not sure I understood any of the directly above. I think that's what I just did was navigate there? I just posted the error message. And I'm aware of my system's python vs. other pythons, the only "external" python i have is just the IDLE program. The rest is the original.
     
  6. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #6
    The error message you got was no such file or directory. You need to navigate to the correct folder first using cd (change directory) and then when you are in the correct folder then type python filename.py.
     
  7. Nicolaius thread starter macrumors newbie

    Joined:
    Jan 4, 2009
    #7
    Ah ok I understand now thank you. But I realized today I probably should have made myself clearer, what I really want to do is convert my .py file somehow to a straight-up executable so that I can just double click and run it.
     
  8. Nicolaius thread starter macrumors newbie

    Joined:
    Jan 4, 2009
    #8
    Ok, so in order to do what i just asked above (make a straight-up application from python code), I did some research and found out I apparently need something called py2app. This is a python egg, which I had no idea how to install. I read a bit and opened terminal and got permission denied, so then i did the sudo thing and typed in my password and then it gave me this error:

    sudo: /Users/Nicola/Desktop/setuptools-0.6c9-py2.5.egg: command not found


    great. Nothing seems to work for me these days *sigh*.
     

Share This Page