Executing scripts

Andy Jewell andy at wild-flower.co.uk
Fri Jul 11 01:01:44 CEST 2003

On Thursday 10 Jul 2003 5:31 pm, Peter Hansen wrote:
> Ken Fettig wrote:
> > I am having a problem executing scripts from python. The script is
> > located at C:\Python22\learn and is named more.py. This is an example
> > from the Programming Python book by Mark Lutz published by O'Reilly. I
> > have tried how the author outlines to execute the script but it doesn't
> > work. I am on a Windows 2000 machine.
> > The example shows to, at the command line, enter C:\Python22\learn>python
> >
> > more.py more.py. I get the following output:
> > >>> C:\Python22\learn>python more.py more.py
> >
> >   File "<stdin>", line 1
> >     C:\Python22\learn>python more.py more.py
> >      ^
> > I have tried many combinations all unsuccessfully.  Can someone please
> > help me????
> You are not at the right command line.  The >>> indicates you have already
> run Python, but are trying to execute a DOS command line at the *Python*
> prompt.
> See  http://www.python.org/cgi-bin/faqw.py?req=show&file=faq08.018.htp
> -Peter


You need:


if you are already at the PYTHON command line.

In computer books, it is convention to usually show the PROMPT as well as the 
command you should enter  (The prompt is the computer program's signal to the 
user (you!) that it's ready for you to type something). The 
"C:\Python22\learn>" bit is the DOS (or win 2000 CMD) PROMPT.  The PYTHON 
PROMPT is ">>>".

DOS (or WIN 2k CMD.EXE) doesn't understand PYTHON commands.
PYTHON doesn't understand DOS commands.

To get a win 2k CMD prompt, click Start/Run...  and enter CMD into the prompt.  
A black box will appear with the DOS prompt in it. If you then type...

c:\python22\python c:\python22\learn\more.py

...it should launch your program.  Python is probably on your PATH environment 
variable, so you *may* be able to get away with (note the prompt!!):

C:\>cd python22
C:\Python22>python learn\more.py

... try it and see, but remember, don't type the PROMPTS!

hope that helps

More information about the Python-list mailing list