Problem while importing GDAL: ImportError, library not loaded, image not found

Since yesterday, I try to import some libraries, such as GDAL (or iris), and I always get the same output.

>>> 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 

I searched in my files and found:

  • 1 file containing libicui18n
  • 2 files containing _gdal.so

    /Users/zoran/anaconda/pkgs/icu-54.1-0/lib/libicui18n.54.1.dylib

    /Users/zoran/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so

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

This morning I can import gdal without any problems and all of a sudden (I don't know what I did) it was completely impossible.

I tried: - uninstall / install gdal - uninstall / install anaconda and install gdal again - create various new environments (in python2 and python3) and install only gdal

I do not know what libicui18n.56.dylib , rowter libgdal.20.dylib .

When I type otool -L with the pathname above, I get:

 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) 

When I print conda info:

  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 

I wonder how are libraries stored in the wrong pointer somehow?

I saw a lot of similar problems, but did not find anything to solve the problem.

thanks for the help

+5
source share
2 answers

I have the same problem.

 conda install -f jpeg=8 conda install libgdal 

solve my problem

+3
source

I found a solution to my problem here .

Thanks for the clear explanation of "ocefpaf":

You have a problem similar to usuall mismatch between conda-forge and default. Can you try the following instructions (if you want of course, use conda-forge gdal):

  • Make sure you have the latest conda to use the channel preference feature. You can do this by issuing the conda conda update in the root env of your conda installation.

  • Edit your .condarc file and place the forge on top of the default values. Usually .condarc lives in your home directory. See mine below. (Note that the more channels you have, the more likely it is to run into problems. I recommend having only the default and conda-forge values.)

  • Run the following commands to verify the installation:

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

If you get 2.1.1, you have successfully installed the latest version from conda-forge. We always recommend that users work with envs as an example above. But you do not need to use Python 3.5 (conda-forge has 3.4 and 2.7), and you do not need to specify env TEST_GDAL.

And here is my .condarc file.

 > cat .condarc channels: - conda-forge - defaults show_channel_urls: true 
+2
source

Source: https://habr.com/ru/post/1258471/


All Articles