[IPython-dev] Weird PYTHONPATH, etc. issue

David Warde-Farley d.warde.farley at gmail.com
Thu Sep 27 15:12:28 EDT 2012


On Thu, Sep 27, 2012 at 8:59 AM, Erik Bray <erik.m.bray at gmail.com> wrote:

> I don't really see this so much as a setuptools problem though.  Your
> sysadmin shouldn't be using PYTHONPATH for this.  I've had to battle
> this a bit at my own institution.  The problem with using PYTHONPATH
> to add site-specific site-packages directories are many-fold.  For
> one, if the user then messes with their PYTHONPATH they suddenly can't
> `import numpy` anymore and come complaining that numpy broke or
> something like that.  PYTHONPATH should be there as an easy way for
> the user to optionally add additional paths to the front of their
> sys.path.  So when it's used like this it basically takes away your
> freedom to customize anything on your path at all since the contents
> of PYTHONPATH come first.  Sure you can always add your stuff to the
> front of PYTHONPATH too, but a lot of users get confused by that.

Prepending to an environment variable to override things is a pretty
standard UNIXy thing to do. Same thing appears in Java with CLASSPATH,
etc., and it pretty much mirrors PATH in that respect. I guess it
could confuse novices, you're right.

> What the sysadmin *should* be doing is adding a sitecustomize.py
> somewhere on the standard sys.path (in lib/pythonX.Y/site-packages for
> example) and adding any custom paths there, while leaving your
> PYTHONPATH alone.  As mentioned elsewhere in this thread
> usercustomize.py can also be used.

Are you sure this would solve the issue? If all of the stuff in all of
the site-packages directories is processed before PYTHONPATH is even
touched, then I guess it might.

David



More information about the IPython-dev mailing list