Jeremy Jacob
Jeremy Jacob

Reputation: 19

I cannot get my Python 3.2.2 interpreter to run scripts (.py files) on Windows 7

I'm relatively new to Python (and programming in general for that matter) and have been using Dick Baldwin's tutorial "Learn to Program using Python" to teach myself. It's been going pretty well but I've hit a pretty big snag. Whenever I try to run a script (`junk.py, which I've placed in C:\Python32) in the Windows Command Prompt this keeps happening:

C:\Users\jeremy>cd C:\Python32

C:\Python32>python junk.py
  File "junk.py", Line 1
     Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on
 win 32

Syntax Error: Invalid Syntax

I know I have successfully added C:/Python32 to my list of variables and have no problem running python through my command prompt and [I am pretty sure at least] I have followed all of Dick Baldwin's instructions correctly. Does anyone have any suggestions as to why I can't run junk.py?

Upvotes: 1

Views: 2034

Answers (1)

joaquin
joaquin

Reputation: 85615

I got your traceback:

C:\Python32>python junk.py
  File "junk.py", line 1
    Python 3.2.2 (default, Sep  4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win32
             ^
SyntaxError: invalid syntax

For this my file junk.py has to be (oh! this is really amazing) like this:

Python 3.2.2 (default, Sep  4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
print ("Hello")

that obviously is not a correct python file.

Your junk file has to contain just:

print("Hello Word")

The Python shell is not the place to edit your files. Use IDLE for that or any text editor from notepad to a full IDE passing through Geany, PyScripter or whatever you prefer

Upvotes: 5

Related Questions