[Python-de] Python 2.7: sys.path vs. PYTHONPATH
Ole Streicher
ole-usenet-spam at gmx.net
Fr Sep 16 10:26:30 CEST 2011
Hallo,
ich habe gerade ein eigenartiges Problem nach dem Übergang von Python
2.6 auf 2.7. Einige Pakete werden bei mir lokal installiert,
z.B. pyfits, mittels setuptools
$ export PYTHONPATH=/mylocal/python/lib64/python2.7/site-packages/
$ python setup.py install --prefix=/mylocal/python
$ ls -l $PATHONPATH
drwxr-xr-x 4 oles ata 4096 Sep 16 09:52 distribute-0.6.19-py2.7.egg
-rw-r--r-- 1 oles ata 286 Sep 16 10:16 easy-install.pth
drwxr-xr-x 4 oles ata 34 Sep 16 09:52 pyfits-3.0-py2.7-linux-x86_64.egg
-rw-r--r-- 1 oles ata 30 Sep 16 09:52 setuptools.pth
-rw-r--r-- 1 oles ata 2362 Sep 16 09:52 site.py
-rw-r--r-- 1 oles ata 1757 Sep 16 09:52 site.pyc
$
Den Pfad möchte ich jetzt in einem Script verwenden:
-----------8<-----------------
#!/usr/bin/env python
import sys
sys.path.append('/mylocal/python/lib64/python2.7/site-packages/')
import pyfits
print pyfits.__version__
-----------8<-----------------
$ unset PYTHONPATH
$ python test.py
Traceback (most recent call last):
File "test.py", line 4, in <module>
import pyfits
ImportError: No module named pyfits
$
Unter 2.6 hatte das noch so funktioniert. Was hat sich da verändert?
Viele Grüße
Ole
Mehr Informationen über die Mailingliste python-de