Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Gdal not working

Tags:

python

gdal

I used conda install -c conda-forge gal to install the GDAL package. However, I got a following error in importing the package.

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

I tried the followings but they didn't work for me:

conda upgrade numpy

conda install libpng

Does anyone know what I should do?

like image 328
ryurruuggbbyy Avatar asked Sep 16 '25 21:09

ryurruuggbbyy


1 Answers

I use anaconda as well and have also had issues installing GDAL in the past. Instead I usually download a wheel from Christoph Gohlke and do pip install <file_name>.whl and it works.

like image 180
Rick supports Monica Avatar answered Sep 19 '25 10:09

Rick supports Monica