Python 3.2.3

Discussion in 'Mac Programming' started by dboxall123, Sep 26, 2012.

  1. dboxall123 macrumors newbie

    Joined:
    Sep 26, 2012
    #1
    Hi everyone
    I've recently decided to learn about programming, and i read on the net that python is one of the easy ones. So i've learnt some of the basics online and decided to download the actual programme. I downloaded and installed the latest version(python 3.2.3) to my mac OS X 10.6.8. The ython shell is working fine, but when i save something and try to open it in the launcher (even the most basic print("Hello World"), Terminal wont run. Anyone got any ideas what i'm doing wrong?
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    It is pretty hard to diagnose the problem from what you have said. The best I can do is offer the steps required to run a Python program from the terminal.

    • Write your Python code using a text editor
    • Save the file with a .py extension
    • Open terminal
    • Navigate to the folder where you saved the .py file using cd (for example if you saved the file in Documents you would execute cd /Users/<your_username>/Documents)
    • Type python3 scriptname.py

    This should run the Python script using your installation of Python 3.2.3. You must use python3 on the command line otherwise you'll end up using the version of Python that is built into Mac OS X (currently 2.7.3 iirc).
     
  3. dboxall123 thread starter macrumors newbie

    Joined:
    Sep 26, 2012
    #3
    Thanks for your help mate. I've just tried that and it says 'Permission Denied'. I really don't understand why it won't let me use it. If I type 'python3', it opens python 3.2.3, but then if I try opening my programme it just opens it in a new terminal window! This is doing my head in!
     
  4. Fed macrumors 6502

    Joined:
    Jul 7, 2012
    Location:
    Liverpool.
    #4
    Are you using Python3 for any specific reason? If not, Mac comes with Python already installed. On my Mountain Lion system, it's 2.7.2 so unsure what it is on your version. Therefore just head to your file in Terminal and then python file.py

    Before you do that, as current user, do:

    1. touch file.py
    2. vi file.py
    3. Input some code (or... Hit 'i', then type 'print "hello"', hit 'esc', ':', 'wq', 'enter')
    4. python file.py

    You shouldn't have any permission issues then.

    EDIT: Actually, after properly reading your post, what is your script doing?
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    Your descriptions are too brief and too vague. We need specific details.

    Post the actual command-line you used in Terminal. The one that doesn't work, and the one that does.

    Describe exactly what you did for "If I try opening my programme it just opens it in a new terminal window". If that involved commands typed in a Terminal windows, post them. If it involved double-clicking a file in the Finder, say "I double-clicked a file in the Finder", and post the contents of that file.

    Post the actual output, whether that's an error message or python prompt.

    Post the actual python code.

    Select and copy directly from the Terminal window, then paste it into a post.
     

Share This Page