[Tutor] How to run a python script

Alan Gauld alan.gauld at btinternet.com
Sat Feb 20 19:30:49 EST 2016


On 20/02/16 16:25, Erol Gericke wrote:

> However I am unable to run any scripts.
> 
> When I type (into the COMMAND PROMPT window) python test.py or
> python C:\python27\test.py      I get SyntaxError: invalid syntax

As Chris has hinted it sounds like you are running the script
at the wrong command prompt.

In general the Python prompt >>> is used to enter code
snippets directly.

The OS command prompt (C:\Windows> or similar) is used
to run Python script files.

To get an OS command prompt hit WindowsKey->Run and
type CMD and click OK. (You can also create a desktop
shortcut if you prefer.)

Also, for future reference it will help if you send
(cut n paste) the full error message not just a summary.
It contains a lot of useful data that helps pinpoint
the issue, once you learn to read it.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list