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

John Machin sjmachin at lexicon.net
Mon May 6 19:40:20 EDT 2002


"Steve Holden" <sholden at holdenweb.com> wrote in message news:<yNuB8.58294$v92.20236 at atlpnn01.usenetserver.com>...
> "Tiberius Teng" <tiberius at ms28.hinet.net> wrote in message
> news:6c92a8bc.0205060225.46b1c6c9 at posting.google.com...
> > robline at purdue.edu (Rob Lineberger) wrote in message
>  news:<84773476.0205052134.8c1d533 at posting.google.com>...

[Rob Lineberger]
Tried setting PYTHONPATH to C:\Python22\Lib but that didn't work
either.

-> PYTHONPATH should include that already.

[Tiberius Teng]
However if you put your spam.py in C:\Python22\Lib then typing 'import
spam' inside Pythonwin / IDLE should work ...

-> Ugh. *DON'T* put your own files in there. Do you really want to run
the risk of overwriting a Python-supplied file with one of your own?
Also think ahead to when the next version of Python comes out. Do you
really want to have to move all your files to c:\python23\lib ? How
will you know which are yours?

[Rob Lineberger]
I'm trying to learn Python
[Steve Holden]
... writing a site-specific <python>/Lib/sitecustomize.py

-> Correct, but is this useful advice to a newbie at the level of
"can't work out where to put his module so that he can import it"?

Here's an alternative:
1. Make a directory called (say) c:\mypy.
2. Save spam.py in c:\mypy
3. Fire up a DOS box / Command Prompt / whatever window.
4. DOS_prompt> cd \mypy
5. DOS_prompt> python
6. >>> import spam
7. >>> spam.some_function()



More information about the Python-list mailing list