2016-10-19 75 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 

解决我的问题

相关问题