2015-11-06 155 views
8

我用使用conda安裝gdal?

conda install gdal 

安裝GDAL包。但是在導入軟件包時出現以下錯誤。

>>> from osgeo import gdal 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 21, in <module> 
    _gdal = swig_import_helper() 
    File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 17, in swig_import_helper 
    _mod = imp.load_module('_gdal', fp, pathname, description) 
ImportError: dlopen(/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so, 2): Library not loaded: libgdal.20.dylib 
    Referenced from: /Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so 
    Reason: image not found 
>>> from osgeo import ogr 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 21, in <module> 
    _gdal = swig_import_helper() 
    File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 17, in swig_import_helper 
    _mod = imp.load_module('_gdal', fp, pathname, description) 
ImportError: dlopen(/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so, 2): Library not loaded: libgdal.20.dylib 
    Referenced from: /Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so 
    Reason: image not found 

我應該怎麼做才能在Python中導入GDAL?

+0

我試過這個,但事實證明,它不起作用... http://stackoverflow.com/questions/28848270/import-matplotlib-pyplot-gives-importerror-dlopen-library-not-loaded-libpng1/31892421 #31892421 –

+0

它的工作原理。許多感謝作者 http://stackoverflow.com/questions/28848270/import-matplotlib-pyplot-gives-importerror-dlopen-library-not-loaded-libpng1/31892421#31892421 –

+3

這沒有解決我的問題。:( –

回答

12

對於Windows用戶(截至2015年12月):

conda install gdal 
conda upgrade numpy 

安裝@中會降級numpy的,所以再升級它備份。 我最近有機會使用Windows進行更改,現在我很驚喜地發現gdal「有效」。

世界各地的Windows + python + gis人都應該慶祝這一點。 (即@中,蟒蛇進去很容易地在Windows ...不,Windows是一步步接近到Linux;))