[GIS] ImportError installing GDAL on Ubuntu 14.04 with Anaconda Python 3.5

anacondagdalpython

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

Best Answer

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.

Related Question