Python is easy?

Peter Hansen peter at
Tue Aug 13 22:11:33 EDT 2002

Jonathan Driller wrote:
> Jonathan
> "Steve Holden" <sholden at> wrote:
> > Jonathan Driller wrote:
> > > [...]
> > > Can anyone assist here? My evangelist can't figure it out...
> >
> > Get another evangelist :-) Then, at the command line prompt (D:>, or
> > whatever your interactive wondow gives you) CD into the directory containing
> > your script and enter
> >
> >     python

> Much thanks and I agree with your first comment. Possibly something
> else is going on - what you suggested did not work. But if I open the
> Python command line I can do things like >>>3 + 3   >>>6 - so Python
> is working. Any other ideas?

I have a few ideas, starting with "provide much more information when
asking questions for a while".  For example "did not work" means what?
What error message did you see, and what *exactly* did you try to do.
Believe me, Steve's advice is much more accurate than anything your
evangelist has told you so far, except the part about Python being 
good!  :-)

Here are a few more things that might help you.

1. The "Python command line" you are running is probably a menu item
in your Start menu, right?  If you run that, you cannot use it to 
run Python scripts just by typing the name of the script "".
Inside this command line (the interactive interpreter) you must use
the "import" statement, as in "import test1", but that's really not
quite how you would normally run something like this.

2. At the MSDOS prompt, if you type "SET" and look at the PATH variable
it should contain the folder in which your PYTHON.EXE file lives.  Check
that it does.  Type "PYTHON" by itself at a prompt and make sure you 
get into the interactive interpreter (signified by the >>> prompt).
If that works, exit again by typing Ctrl-Z, so you are back at the DOS
prompt again (C:\WINDOWS or whatever it is for you).

3. Change to the directory where your test script lives.  You should be
able to see it if you type "DIR TEST1.PY", something like this:

   Volume in drive C is DRIVE1-1
   Volume Serial Number is 2E17-18E1
   Directory of C:\

  TEST1    PY            322  08-04-02 12:35a
           1 file(s)            322 bytes
           0 dir(s)          432.06 MB free

I'm guessing you already know all this, but you've given little to
indicate that you do so forgive me if it seems patronizing.

4. If you can see that, and #2 worked, *here* is how you normally run
a Python script at the command prompt (assuming your file
is in a folder called C:\FILES):

C:\FILES> python

Traceback (most recent call last):
  File "", line 1, in ?
    import urlopen
ImportError: No module named urlopen

Is that what you got before when you said "it didn't work"?  Well,
that's because the _script_ is wrong, not the method of running it.

Let us know if this is the point you are at and we can start pointing
out the flaws in the script, starting with the fact that there is
no "urlopen" module...


More information about the Python-list mailing list