2017-08-08 30 views
0

我收到以下錯誤,當我嘗試導入安裝GDAL:無法導入Mac上@中,通過蟒蛇

>>> from osgeo import gdal 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "//anaconda/lib/python3.6/site-packages/osgeo/__init__.py", line 21, in <module> 
    _gdal = swig_import_helper() 
    File "//anaconda/lib/python3.6/site-packages/osgeo/__init__.py", line 17, in swig_import_helper 
    _mod = imp.load_module('_gdal', fp, pathname, description) 
    File "//anaconda/lib/python3.6/imp.py", line 242, in load_module 
    return load_dynamic(name, filename, file) 
    File "//anaconda/lib/python3.6/imp.py", line 342, in load_dynamic 
    return _load(spec) 
ImportError: dlopen(//anaconda/lib/python3.6/site-packages/osgeo/_gdal.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libgdal.20.dylib 
    Referenced from: //anaconda/lib/python3.6/site-packages/osgeo/_gdal.cpython-36m-darwin.so 
    Reason: image not found 

我已經試過卸載並重新安裝(它的安裝與暢達鍛)更新和檢查,以確保沿路徑的文件存在,但似乎沒有任何工作!我也看了一個線程,建議檢查.condarc文件,但找不到一個。

回答

0

查看關於this頁面的最新評論。這是一個已知的問題。 爲了節省您的點擊:

gdal depends on a huge number of c-libs that need to be pinned down to specific versions to avoid software breakage by mixing versions.

The problem is that different channels pin to different versions. That means you need to "stay" within a "trusted/consistent" pinning scheme.

The Anaconda distribution brings a lot of pre-installed software and, even by adding conda-forge as the preferred channel (placing it on top of defaults), will be hard to get that consistent installation.

We recommend using miniconda and creating envs to "encapsulate" the different cases and get a more stable installation. (Or, like I mention above, if you don't need external channels you can use only defaults.)

+0

行,所以我現在已經做了在終端如下: 暢達創建-n newenv蟒蛇= 3.6 @中 源激活newenv 如果我在我的Spyder確實編碼這意味着我必須在新的環境中打開Spyder?還是有另一種方式? –

+0

@ESchreiber正確,您需要從那裏運行它,或者將其重新安裝到環境中。見[這裏](https://stackoverflow.com/questions/30170468/how-to-run-spyder-in-virtual-environment/30170469)和[這裏](https://stackoverflow.com/questions/34217175/ Spyder的 - 不 - 不磨合,蟒蛇,虛擬環境的窗口-10)。 –

+0

不幸的是我在我的新環境(newenv)中仍然出現類似的錯誤。 「ImportError:dlopen(/Users/echreiber/anaconda/envs/newenv/lib/python3.6/site-packages/osgeo/_gdal.cpython-36m-darwin.so,2):未加載庫:@ rpath/libicui18n。 58.dylib 引用自:/Users/eschreiber/anaconda/envs/newenv/lib/libgdal.20.dylib 原因:找不到圖像「 –