Issue when imoporting GDAL : ImportError, Library not loaded, Image not found
<p>Since yesterday I struggle to import some libraries such as GDAL (or iris) and I allways get the same type of outputs.</p>

<pre><code>&gt;&gt;&gt; import gdal
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "gdal.py", line 28, in &lt;module&gt;
    _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
</code></pre>

<p>I searched in my files and found:</p>

<ul>
<li>1 files containing <code>libicui18n</code></li>
<li><p>2 files containing <code>_gdal.so</code></p>

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

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

<p>/Library/Frameworks/GDAL.framework/Versions/2.1/Python/2.7/site-packages/osgeo/_gdal.so</p></li>
</ul>

<p>This morning I could import gdal without problem and suddenly (I don't know what I did) it was totally impossible.</p>

<p>I tried to:
- uninstall/install gdal
- uninstall/install anaconda and install again gdal
- create different new environments (in python2 and python3) and install only gdal</p>

<p>I don't know what this <code>libicui18n.56.dylib</code> is, neighter <code>libgdal.20.dylib</code>.</p>

<p>When I type otool -L with the name of the paths above I get:</p>

<pre><code>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)
</code></pre>

<p>When I type conda info:</p>

<pre><code>           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
</code></pre>

<p>I am wondering if somehow the libraries are saved in the wrong directrory?</p>

<p>I've seen many similar issues but no trick to fix the problem.</p>

<p>Thanks for helping</p>

<p>I found a solution to my problem <a href="https://github.com/conda-forge/gdal-feedstock/issues/111" rel="nofollow">here</a>.</p>

<p>Thank you for the clear explanation of "ocefpaf":</p>

<blockquote>
  <p>You problem seems like the usuall mismatch between conda-forge and
  defaults. Can you try the following instructions (if you do want to
  use conda-forge's gdal of course):</p>
  
  <ol>
  <li><p>Make sure you have the latest conda to take advantage of the channel preference feature. You can do that by issuing conda update
  conda in the root env of your conda installation.</p></li>
  <li><p>Edit your .condarc file and place the conda-forge on top of defaults. The .condarc usually lives in your home directory. See mine
  below. (Note that the more channels you have you are more likely to
  face issues. I recommend having only defaults and conda-forge.)</p></li>
  <li><p>Issue the following commands to check if you will get the correct installation:</p></li>
  </ol>
</blockquote>

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

<blockquote>
  <p>If you get 2.1.1 you got a successful installation of the latest
  version from conda-forge. We always recommend users to work with envs
  as the the example above. But you do not need to use Python 3.5
  (conda-forge has 3.4 and 2.7 also) and you do not need to name the env
  TEST_GDAL.</p>
  
  <p>And here is my .condarc file.</p>
</blockquote>

<pre><code>&gt; cat .condarc
channels:
- conda-forge
- defaults
show_channel_urls: true
</code></pre>

python anaconda importerror gdal