2016-10-19 76 views
5

由於昨天我很難導入一些庫,如GDAL(或虹膜),我總是得到相同類型的輸出。插入GDAL時出現問題:ImportError,Library not loaded,Image not found

>>> import gdal 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "gdal.py", line 28, in <module> 
    _gdal = swig_import_helper() 
    File "gdal.py", line 24, in swig_import_helper 
    _mod = imp.load_module('_gdal', fp, pathname, description) 
ImportError: dlopen(./_gdal.so, 2): Library not loaded: @rpath/libicui18n.56.dylib 
    Referenced from: /Users/zoran/anaconda/lib/libgdal.20.dylib 
    Reason: image not found 

我搜索我的檔案,發現:

  • 1文件含含_gdal.so

    /Users/zoran/anaconda/pkgs/icu-54.1- libicui18n

  • 2檔0/lib/libicui18n.54.1.dylib

    /Users/zoran/anaconda/lib/python2.7/site-pac kages/OSGEO/_gdal.so

    /Library/Frameworks/GDAL.framework/Versions/2.1/Python/2.7/site-packages/osgeo/_gdal.so

今天早上,我可以導入@中沒有問題,突然(我不知道我做了什麼),這是完全不可能的。

我想: - 卸載/安裝@中 - 卸載/安裝蟒蛇和再次安裝GDAL - 創建不同的新環境(在python2和python3),並只安裝GDAL

我不知道是什麼這個libicui18n.56.dylib是更接近libgdal.20.dylib

當我與我上面的路徑名鍵入otool -L得到:

libicui18n.54.dylib (compatibility version 54.0.0, current version 54.1.0) 
@loader_path/./libicuuc.54.dylib (compatibility version 54.0.0, current version 54.1.0) 
@loader_path/./libicudata.54.dylib (compatibility version 54.0.0, current version 54.1.0) 
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0) 
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0) 
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) 

@rpath/libgdal.1.dylib (compatibility version 20.0.0, current version 20.5.0) 
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0) 
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1) 

/Library/Frameworks/GDAL.framework/Versions/2.1/GDAL (compatibility version 22.0.0, current version 22.1.0) 
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0) 
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) 

當我鍵入暢達信息:

  platform : osx-64 
     conda version : 4.2.9 
    conda is private : False 
    conda-env version : 4.2.9 
conda-build version : 2.0.2 
    python version : 2.7.12.final.0 
    requests version : 2.11.1 
    root environment : /Users/zoran/anaconda (writable) 
default environment : /Users/zoran/anaconda 
    envs directories : /Users/zoran/anaconda/envs 
     package cache : /Users/zoran/anaconda/pkgs 
     channel URLs : https://conda.anaconda.org/anaconda/osx-64/ 
         https://conda.anaconda.org/anaconda/noarch/ 
         https://conda.anaconda.org/scitools/osx-64/ 
         https://conda.anaconda.org/scitools/noarch/ 
         https://conda.anaconda.org/conda-forge/osx-64/ 
         https://conda.anaconda.org/conda-forge/noarch/ 
         https://repo.continuum.io/pkgs/free/osx-64/ 
         https://repo.continuum.io/pkgs/free/noarch/ 
         https://repo.continuum.io/pkgs/pro/osx-64/ 
         https://repo.continuum.io/pkgs/pro/noarch/ 
     config file : /Users/zoran/.condarc 
     offline mode : False 

如果莫名其妙地庫保存在我想知道錯誤的directrory?

我見過很多類似的問題,但沒有解決問題的竅門。

感謝您的幫助

回答

2

我找到了解決我的問題here

感謝您對「ocefpaf」的明確解釋:

您的問題似乎是暢達,鍛造和 默認的usuall不匹配。你可以試試下面的說明(如果你想當然 使用暢達鍛的GDAL):

  1. 請確保您有最新的暢達採取信道擇優功能的優勢。您可以通過在conda安裝的根環境中發佈conda更新 conda來實現此目的。

  2. 編輯.condarc文件並將conda-forge放在默認值之上。 .condarc通常位於您的主目錄中。見下面我的 。(請注意,更多的渠道,你有你更有可能 面對的問題,我建議只有違約和暢達鍛。)

  3. 發出以下命令來檢查,如果你會得到正確的安裝:

conda create --yes -n TEST_GDAL python=3.5 gdal 
source activate TEST_GDAL 
python -c "from osgeo import gdal; print(gdal.__version__)" 

如果你2.1.1你得到的來自暢達鍛最新版本 安裝成功。作爲上面的例子,我們總是推薦用戶使用envs 。但是你不需要使用Python 3.5 (conda-forge也有3.4和2.7),你不需要命名env TEST_GDAL。

這裏是我的.condarc文件。

> cat .condarc 
channels: 
- conda-forge 
- defaults 
show_channel_urls: true 
3

我有同樣的問題。

conda install -f jpeg=8 

conda install libgdal 

解決我的問題

相關問題