[Tutor] Python Trouble, Please Help!

Alan Gauld alan.gauld at btinternet.com
Thu Aug 8 09:29:29 CEST 2013


On 25/07/13 00:23, Jonathan Hong wrote:

> because of my lack of computer knowledge. When I do put in python
> helloworld.py into the command prompt line, the computer gives me a
> response of: "python: can't open file 'hello.py': [Errno 2] No such file

You need to supply the full path to the file (or be in the same 
directory as the file) when you try to run it.

Mostly on Windows you can run scripts from Windows explorer but for 
simple scripts (like hello world) the window appears and then 
dissappears too quickly to see it. You can most easily get around that 
by putting one of:

raw_input("Hit Enter to quit")   # for Python v2

input("Hit Enter to quit")   # for Python v3


as the last line in your script.

You might find that technique easier than using the CMD window.
But the CMD window is better when things go wrong - it lets you see any 
error messages,...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list