Trying to use "Programming Python" (Lutz), getting module errors.

Ingar Smedstad st00535 at rasmus.uib.no
Wed May 8 12:37:28 EDT 2002


"Rob Lineberger" <robline at purdue.edu> wrote in message
news:84773476.0205060722.6f377f52 at posting.google.com...
> >
> > I would recommand you start learning Python by reading "Learning
> > Python" (also by Mark Lutz & David Ascher), not "Programming Python"
> > ... :)
>
> Sorry, it was late and I was befuddled.  I am indeed using the book
> "Learning Python".
>
> > However if you put your spam.py in C:\Python22\Lib then typing 'import
> > spam' inside Pythonwin / IDLE should work ...
>
> Then I am stumped.  This is what I did (From memory, so if my code is
> wrong please refer to the book).  Page 12 says something like:
>
> >>>> print "Hello World!"
>
> Did so and it printed Hello World!.
>
> Then the book says to open a text editor and create a module, for
> example myfile.py looks like this:
>
> title="A Fish Called Wanda"
>
> I created the above file and saved it as myfile.py into the
> C:\Python22\Lib directory.  I went to said directory and confirmed it
> was there.  double clicked it and a black DOS window flashed briefly
> on the screen.

Doubleclicking on .py files in windows usually gives that response unless
the code halts somewhere (ie. waiting for input.) The simple learning files
just prints some output if I remember correctly. To run any python file in
windows you can do it the command line way. It works very much like on a
*nix platform. Open a command prompt and cd to the directory of the *.py
file you want to run. Then you just type 'python <filename>.py'. As long as
the python executable is in your %PATH% of course. Oh, and I have also found
that doskey is a very useful command. Gives you input history.

> Then I opened pythonwin and typed:
>
> >>>> import myfile.py
>
> Got an error that read something like this:
>
> "No such module exists"
>
> Thanks again for any light you can shed.





More information about the Python-list mailing list