[PEAK] dumb question about easy_install

Phillip J. Eby pje at telecommunity.com
Wed Jun 28 12:22:45 EDT 2006

At 11:52 AM 6/28/2006 -0400, Michael Bayer wrote:
>I noticed after upgrading setuptools recently that PYTHONPATH usage
>has gotten more complicated.  I.e., if I open a shell and just
>arbitrarily set PYTHONPATH to a directory where i have some code
>somewhere, the "official" version of the package in site-packages
>insists on being used, as though PYTHONPATH doesnt exist.  to get it
>to work, i had to blow away the package in the site-packages/easy- 
>install.pth file....not such a terrific solution.
>then I noticed in the docs that there is a "traditional" pythonpath- based 
>installation method.  but this seems to be more about, "you
>want to install your package in a PYTHONPATH directory instead of
>site-packages".  which is not what im looking for.
>i want setuptools to put things in site-packages like it always does;
>but i want to be able to occasionally override the existence of the
>package in the normal way by setting PYTHONPATH to some local
>directory somewhere.   just like we do in java with CLASSPATH, or in
>a unix distro with LD_LIBRARY_PATH, or perl with PERL5LIB...is this
>no longer possible with setuptools?

The issue is that setuptools-installed packages take precedence over any 
other form of packages, in order to prevent package version conflicts.  For 
something on PYTHONPATH to override a site-packages egg, it has to be a 

If you want to put a source directory on PYTHONPATH, you should use 
"setup.py develop" with setuptools; this will put a .egg-link file in the 
target directory that points to your development source code, e.g.:

cd /my/source
PYTHONPATH=/some/dir python setup.py develop -d /some/dir
PYTHONPATH=/some/dir python

>or is this just a bug ?

No, it's as-designed, but it's probably not as well-documented as it should be.

Note also that you can avoid this behavior by using -m with easy_install, 
and this will not put the packages on sys.path by default, so PYTHONPATH 
will take precedence.  However, packages installed with -m won't be 
importable unless you pkg_resources.require() them in the 
interpreter.  (Scripts installed via easy_install will work correctly, 
however, whether you use -m or not.)

More information about the PEAK mailing list