I am a programming (and Python) novice. I am unable to run any python script in command prompt of my WinXP 64-bit laptop. I assigned the path and confirmed it by typing set
You're inside the python interpreter not the windows command line.
To open the windows command line go to
Start -> All Programs -> Accessories -> Command Prompt
Then you will need to change into the directory where you have stored hello.py. If it was on your desktop you would do:
cd Desktop
and then after that you could do:
python hello.py
and it would work.
python
is the command you use to run the script so you run it in the shell. In Windows, that would be the command prompt (Run > "cmd").
You should type this
python hello.py
at the dos/cmd prompt, not inside the Python Interpreter
Do it like this:
Go the directory(python32 in my example) and type python hello.py
.
If you only type python
in cmd then it'll launch the python interpreter after that python hello.py
will return Syntax error.
You are typing the command inside the Python shell, do it from the DOS prompt.
I.e.,
C:\somepath\> python hello.py
since you already have the python executable on the path (the number 1 problem usually when things don't work), you should be set to go.
Another way of doing it inside the interpreter is by just importing the name of the module without the .py so for example, in your case:
>>>import hello
would return
Hello, World!