How to insert my own module in front of site eggs?

Roy Smith roy at panix.com
Thu Nov 17 20:36:38 EST 2011


In article <874ny2fzn6.fsf at no-fixed-abode.cable.virginmedia.net>,
 Paul Rudin <paul.nospam at rudin.co.uk> wrote:

> Roy Smith <roy at panix.com> writes:
> 
> 
> > But, you're talking about installers.  I'm talking about if I've already 
> > got something installed, how do I force one particular python process to 
> > pull in a local copy of a module in preference to the installed one?
> >
> > In some cases, I own the machine and can make changes to /usr/local/lib 
> > if I want to.  But what about on a shared machine?  I don't want to (or 
> > perhaps can't) play with what's in /usr/local/lib just to make my stuff 
> > load first.
> 
> Maybe I'm missing something - but if I want to do this I just mess about
> with sys.path at the top of my python script/program. Always seems to
> work... is there a situation in which it doesn't?

What if the first import of a module is happening inside some code you 
don't have access to?

It just seems mind-boggling to me that PYTHONPATH doesn't preempt 
everything else.



More information about the Python-list mailing list