[Distutils] easy_install and sys.path
Phillip J. Eby
pje at telecommunity.com
Wed May 9 19:41:52 CEST 2007
At 08:25 AM 5/9/2007 +0100, Bryan Lawrence wrote:
>Oh I know I shouldn't mix two pythons, but I've never had them "mixed" before.
>(We have run our own python in /usr/local for yonks without any bad karma
>until now). It's only the advent of eggs, which push things to the top of
>sys.path that causes a problem. It would appear that I'm not the only person
>who has the problem (e.g. see
>So, my question to this list is "why"?
>Why does easy_install put things in the front of sys.path?
>Presumably there is
>some good reason (perhaps it is the only way to ensure that your dependency
>libraries are the ones that are picked up, I guess there is a risk that older
>libraries might exist
That's precisely the reason. Until it started doing this, it had to
try to either delete those conflicting libraries, or refuse to
install anything until the user fixed it.
>I've been a big fan of eggs, but I've just slammed into a wall. I can't
>believe that I'm the only one for whom this may be a problem. I now need to
>work out what, if anything, I need to do about it (change my behaviour, find
>out something I didn't know about egg installation, provide a suggested
>optional change to egg behaviour, go home have a drink etc ...)
You can use the "-m" option to easy_install, in which case eggs will
only be added to sys.path when you ask for them. Just delete your
existing easy-install.pth file (leaving the setuptools.pth file in
place). Then, your existing eggs will still be there, and any
easy_install-provided scripts will still work. You just will have to
manually require() any eggs you want when you run any program that's
not a setuptools-generated script, or when you fire up the
interpreter (unless you modify your .pythonrc to require() the eggs you want).
> > '/usr/local/lib/python2.5/site-packages',
The fact that this is in your sys.path is what's causing those eggs
to be added, btw. It appears your distro may have either patched
/usr/lib/python2.5/site.py to include the /usr/local tree, or you
have a .pth file in /usr/lib/python2.5/site-packages that adds the
More information about the Distutils-SIG