Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dboxall123

macrumors newbie
Original poster
Sep 26, 2012
2
0
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?
 
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?

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).
 
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!
 
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!

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?
 
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!

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.