3

I installed the GDAL library on Ubuntu 14.04 through the Anaconda (Python 3.5) distribution. After installation, which seems to work fine, I try importing it and I get this error:

>>>from osgeo import gdal

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/klab/anaconda3/lib/python3.5/site-packages/osgeo/__init__.py", line 21, in <module> _gdal = swig_import_helper()
  File "/home/klab/anaconda3/lib/python3.5/site packages/osgeo/__init__.py", line 17, in swig_import_helper_mod = imp.load_module('_gdal', fp, pathname, description)
  File "/home/klab/anaconda3/lib/python3.5/imp.py", line 242, in load_module return load_dynamic(name, filename, file)
  File "/home/klab/anaconda3/lib/python3.5/imp.py", line 342, in load_dynamic return _load(spec)

ImportError: libcom_err.so.3: cannot open shared object file: No such file or directory

I tried installing through PIP and Conda install commands with the same error. I did go to the directory where this should exist, and it indeed is missing. I figured that if this were a true dependency, it would have installed automatically. Has anybody else had this problem?

I was trying to follow this link, but it wasn't helpful. https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/2-bXTbSiQzg

1 Answer 1

1

I also installed the GDAL library, but on Debian Jessie, through the Anaconda (Python 3.5) distribution. In my case, I got the following error which pointed out to a missing libexpat.so.0 file or directory (different of your libcom_err.so.3):

>>> from osgeo import gdal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zeito/anaconda3/lib/python3.5/site-packages/osgeo/__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "/home/zeito/anaconda3/lib/python3.5/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
  File "/home/zeito/anaconda3/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/zeito/anaconda3/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libexpat.so.0: cannot open shared object file: No such file or directory

I solved my issue by creating a symbolic link named libexpat.so.0 pointing to libexpat.so in this way:

ln -s /home/zeito/anaconda3/lib/libexpat.so /home/zeito/anaconda3/lib/libexpat.so.0

as it can be observed at the next image after importing GDAL module:

enter image description here

In your case, try out:

ln -s /home/klab/anaconda3/lib/libcom_err.so /home/klab/anaconda3/lib/libcom_err.so.3

I hope that it works.

2
  • I ended up doing sudo ln -s /lib/x86_64-linux-gnu/libcom_err.so.2 /opt/conda/lib/libcom_err.so.3 which worked. Commented Dec 30, 2016 at 20:06
  • There was no version of libcom_err present in my lib dir, so I used locate to find it as per this answer, and symlink did the trick.
    – danwild
    Commented Mar 5, 2019 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.