Import error in conda environment for GDAL

418 Views Asked by At

I am trying to install GDAL==2.2.2 in a conda environment. But I get the following error for some reason:

from osgeo import gdal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hug180/.local/lib/python3.6/site-packages/osgeo/__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "/home/hug180/.local/lib/python3.6/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
  File "/home/hug180/miniconda3/envs/awra_test/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/home/hug180/miniconda3/envs/awra_test/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libimf.so: cannot open shared object file: No such file or directory

libimf seems to be math library for intel compilers. I don't understand this error. No where in /usr/lib or any conda environment lib directories can I find libimf.so.

1

There are 1 best solutions below

0
On

Check if GDAL is properly installed in your conda environment. For that use gdalinfo --version command:

kuba@szostak:~$ conda activate
(base) kuba@szostak:~$ gdalinfo --version

If you see something like GDAL 3.6.2, released 2023/01/02, then everything seems to be fine. More details will be needed to solve your issue.

If you see Command 'gdalinfo' not found, then it seems that you have GDAL python bindings installed, but not GDAL binaries. In that case follow steps in these answers: