Python: what happens during easy_install?

I got a little confused in the files with the eggs and installed them with easy_install, I hope you can help me. (I read about people recommendations on pips, but I would like to understand this before moving on).

If I just copy e, g django_guardian-1.0.2-py2.6.egg , let's say the thumb pointer and the location in, for example, ~/bar/ pointed to by PYTHONPATH, trying to import the content via import guardian will give me importError. This error occurs even if I have easy_install.pth copied to

 import sys; sys.__plen = len(sys.path) ./django_guardian-1.0.2-py2.6.egg import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys '__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) 

Now, using easy_install django-guardian , of course, there was no such problem.

I went to the directory where the egg file was uploaded, and all it contains are the .pth and .egg . I want to know what other procedures / entries easy_install does, something makes the first method unusable ....

+4
source share
1 answer

easy_install uses .pth files to add .egg files to sys.path - a list of places where Python searches for modules to import.

.pth files are processed by the site module, but only in four predefined directories. These directories are platform dependent and are based on the sys.prefix and sys.exec_prefix . Usually, on Unix, /usr/lib/pythonXX/site-packages most noticeable.

Since your custom directory is not one of the directories processed by site , your .pth file will not be processed, and Python will not look inside .egg .

See the site module documentation for more information.

+4
source

All Articles