Python20 and .pth files

greg Landrum gReGlAnDrUm at earthlink.net
Tue Feb 13 22:27:39 EST 2001


This is the second time I've been bitten by this problem in two days, so I
figured that I'd post about it and see what the community consensus is.  If
the community consensus is that I'm an idiot, I'll live with that.  :-)

My system:
I'm running python20 on Win2K (using ActivePython, if that makes any
difference).  I didn't muck about with any of the installation settings, so
python lives in c:/python20

Short form of the problem:
It appears that some "advanced" python applications ignore .pth files at
times.

Specific instances of this happening:
Numeric Python likes to be installed in c:/python20.  It creates a Numeric
subdirectory and puts a Numeric.pth file in c:/python20.  Most of the time
this is just fine.

However... one of the applications I'm working on creates Python COM
servers which import Numeric.  These work fine when I call them from Python
applications (so none of my unit tests broke when I upgraded to 2.0, so I
never noticed the problem).  However, when I create one of these COM
objects from within VB, I get an ImportError for Numeric.  After much
shrieking and pulling of my hair (I'm giving a demo of these objects on
Friday, so I was not pleased to discover that they were mysteriously
broken), I worked out a solution: add c:/Python20/Numeric to my PYTHONPATH
environment variable.  Now everything is happy.

I had noticed similar problems when I tried to use my mod_python based web
stuff, these are also fixed by ensuring that c:/python20/Numeric is in
sys.path.

The Question:
Was it an accident that everything just worked before or has something
changed?  I know old versions of Numeric used to have an installer that may
or may not have set registry keys to help out with this problem.
Are .pth files being deprecated so that we (the users) should start
badgering developers who still ship modules requiring them?

I'm now looking forward to the first time I try to use PIL in one of these
cases and discover that it doesn't work either.  Luckily this time I'll
know how to work around the problem.

-greg



More information about the Python-list mailing list