[Tutor] Getting Started; Syntax Error; Bad Command or File Name

Andrei Kulakov ak@silmarill.org
Wed, 28 Nov 2001 20:47:15 -0500


On Wed, Nov 28, 2001 at 09:34:26AM -0800, Frank Peavy wrote:
> 
> >On Tue, Nov 27, 2001 at 06:31:24PM -0800, Frank Peavy wrote:
> >> Using IDLE
> >> Win 98SE installation
> >>
> >> I keep getting a syntax error when I try to run the "hello world" program
> >> listed at the bottom.
> >> In looking through the TUTOR archives I noticed a solution related to
> >> sys.path that I tried, thinking
> >> that the problems may be related(see below). I thought the problem 
> >might be
> >> related to a PATH problem, but was unsure.
> >> ********************************************************
> >> >>> python hello1.py
> 
> Andrei Kulakov wrote:
> >You're making a common mistake here - confusing two separate
> >environments - msdos prompt and python shell. Msdos prompt looks like
> >this:
> >C:>
> >Python shell looks like this:
> >>>>
> >
> >To run a python script called hello1.py, you should go to msdos prompt
> >(it's in your start menu/programs, at the bottom). Then you go to the
> >dir where that file is, and type python hello1.py.
> >
> >> ********************************************************
> >> My py below
> >> ********************************************************
> >> # File: hello1.py
> >>
> >> from Tkinter import *
> >>
> >> root = Tk()
> >>
> >> w = Label(root, text="Hello, world!")
> >> w.pack()
> >>
> >> root.mainloop()
> >>
> 
> Andrei,
> First of all, I hope I am doing this correctly(by responding in this 
> manner).
> This is what I did:
> 1) Start>Programs>MSDOS prompt
> 2) in the MSDOS box I cd\ to where the hello1.py is located

If this a typo, never mind, but if not, the actual cd command looks like 
C:\ cd python [if your script is in a directory python]

> 3) typed:  python hello1.py
> 
> 4) response was: BAD COMMAND or FILE NAME

Yes, this means python isn't in the PATH. Please refer to what other
people recommended 'cause I haven't used windows in quite some time and
I forgot how to work with paths there..

Although if I remember right, it's easier to simply associate python
with .py extension (it's done somewhere in options in explorer), and
then you'd simply click on that file in explorer and it'd run. But you
also have to put this line at the end of each script:

raw_input("Hit any key to exit..")

The reason you need it is that normally ms-dos program will run and
immediately close on exit, so all you see is a window that flashes
before your eyes and disappears before you can read it. This command
will pause it until you hit any key.

Does anyone remember how to associate python with .py extension?

> 
> Any suggestions?
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org