Import of egg packages installed with easy_install

Alexey Vlasov renton at 1gb.ru
Mon Dec 1 11:37:44 EST 2008


Hi.

There's an already installed with easy_install packet, let's say flup,
to the home catalog:
$ ls -la ~/python/lib/python2.5/site-packages/
total 176
drwxr-xr-x  3 4096 Nov 29 18:57 .
drwxr-xr-x  3 4096 Nov 29 18:51 ..
-rw-r--r--  1 208 Nov 29 18:57 easy-install.pth
-rw-r--r--  1 134573 Nov 29 18:51 flup-1.0.1-py2.5.egg
-rw-r--r--  1 2362 Nov 29 18:51 site.py
-rw-r--r--  1 1853 Nov 29 18:51 site.pyc


$ cat ~/python/lib/python2.5/site-packages/easy-install.pth
import sys; sys.__plen = len(sys.path)
./flup-1.0.1-py2.5.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)

$ echo $PYTHONPATH
/usr/lib64/portage/pym:/home/username/python/lib64/python2.5/site-packages

$ python
Python 2.5.2 (r252:60911, Nov 13 2008, 15:01:36)
[GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import flup

No errors.

Then I create a simple CGI script:
========
#!/usr/bin/python

print "Content-type: text/plain";
print

import sys
sys.path.insert (0,
'/home/username/python/lib64/python2.5/site-packages')
print sys.path
import flup
========

Browser says:
['/home/username/python/lib64/python2.5/site-packages',
'/home/username/http', '/usr/lib64/python25.zip',
'/usr/lib64/python2.5', '/usr/lib64/python2.5/plat-linux2',
'/usr/lib64/python2.5/lib-tk', '/usr/lib64/python2.5/lib-dynload',
'/usr/lib64/python2.5/site-packages']

in error log:
[Sat Nov 29 19:41:15 2008] [error] Traceback (most recent call last):
[Sat Nov 29 19:41:15 2008] [error] File "path.cgi", line 9, in <module>
[Sat Nov 29 19:41:15 2008] [error] import flup
[Sat Nov 29 19:41:15 2008] [error] ImportError: No module named flup


If you start it with console, you get the same, but there appears also
another path:
/home/username/python/lib64/python2.5/site-packages/flup-1.0.1-py2.5.egg

As I understand it is the problem actually, but I can't get why sys.path
doesn't contain this path when I request with HTTP.

-- 
BRGDS. Alexey Vlasov.



More information about the Python-list mailing list