Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Hey, I'm trying to learn how to program so I've installed the latest version of Python and I've been following the Byte of Python tutorial. I'm using Textwrangler I've only gotten as far as the simple "Hello World" intro and I'm already having a problem. I type out the code:

#!/usr/bin/python

#Filename: helloworld.py

print('Hello World')

and save it to my desktop as helloworld.py. I then go into terminal and type "python3 helloworld.py" and I get the following error message:

/Library/Frameworks/Python.framework/Versions/3.1/Resources/Python.app/Contents/MacOS/Python: can't open file 'helloworld.py': [Errno 2] No such file or directory

I was hoping someone could tell me what I'm doing wrong. If I choose to run the script from Textwrangler it operates just fine however I'm not able to access it from the Terminal. Thanks so much!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You need to be in the same directory in the terminal that you saved the file in or you need to specify the full directory on the command line:

cd /path/to/directory
python3 helloworld.py

or

python3 /path/to/directory/helloworld.py

What directory did you save the file to?

share|improve this answer
    
Awesome thank you so much I think I understand how it works now. I just had to specify that it was in /users/username/desktop python3 helloworld.py. Thanks so much for the help! –  Stephen Feb 4 '11 at 17:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.