Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run Python from cmd line

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 path. I have Python32. I get the following message:

>>>python hello.py

File <”stdin”> , Line1
  Python hello.py
             ^
SyntaxError: Invalid syntax

Following is the script I tried:

#!/usr/bin/python
message = "Hello, world!"
print(message)
like image 778
info-nowise Avatar asked Dec 16 '22 22:12

info-nowise


2 Answers

You should type this

python hello.py

at the dos/cmd prompt, not inside the Python Interpreter

like image 147
John La Rooy Avatar answered Dec 21 '22 22:12

John La Rooy


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.

enter image description here

like image 34
Ashwini Chaudhary Avatar answered Dec 21 '22 22:12

Ashwini Chaudhary