Dennis
Dennis

Reputation: 191

libgdal.so.20: undefined symbol

yesterday the code was running but when I run my code today, the following error occurs:

runfile('/media/mattes/data1/dataDMattes/Code/Python/PythonProgram/main.py', wdir='/media/mattes/data1/dataDMattes/Code/Python/PythonProgram')

Traceback (most recent call last):

File "<ipython-input-1-e8fdc416f3c8>", line 1, in <module>
runfile('/media/mattes/data1/dataDMattes/Code/Python/PythonProgram/main.py', wdir='/media/mattes/data1/dataDMattes/Code/Python/PythonProgram')

File "/home/mattes/anaconda3/envs/gmt-python2/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "/home/mattes/anaconda3/envs/gmt-python2/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "/media/mattes/data1/dataDMattes/Code/Python/PythonProgram/main.py", line 17, in <module>
import ogr

File "/home/mattes/anaconda3/envs/gmt-python2/lib/python3.6/site-packages/ogr.py", line 2, in <module>
from osgeo.gdal import deprecation_warn

File "/home/mattes/anaconda3/envs/gmt-python2/lib/python3.6/site-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()

File "/home/mattes/anaconda3/envs/gmt-python2/lib/python3.6/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)

File "/home/mattes/anaconda3/envs/gmt-python2/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)

File "/home/mattes/anaconda3/envs/gmt-python2/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)

ImportError: /home/mattes/anaconda3/envs/gmt-python2/lib/python3.6/site-packages/osgeo/../../../libgdal.so.20: undefined symbol: _ZN11xercesc_3_211InputSource11setEncodingEPKDs

I also tried to reinstall all and installed gdal and libgdal again but the error still occurs. I use a virtual environment in which I have:

gdal                      2.2.4                    py36_0    conda-forge
libgdal                   2.2.4                hc8d23f9_1    anaconda

Well, I know the two are from different sources but this worked until yesterday.

I use Python 3.6.3 with Anaconda in Ubuntu 16.04.

Update

As I found out, this Problem also occur when I use PyCharm instead of Anaconda, with the same error. In this case I use GDAL downloaded with the pip command and a pre installed libgdal.

This is the error message in this case:

Traceback (most recent call last):
File "/opt/pycharm-community-2018.1.4/helpers/pydev/pydev_run_in_console.py", line 52, in run_file
pydev_imports.execfile(file, globals, locals)  # execute the script
File "/opt/pycharm-community-2018.1.4/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/media/mattes/data1/dataDMattes/Code/Python/PythonProgram/main.py", line 18, in <module>
import ogr
File "/opt/pycharm-community-2018.1.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 19, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/lib/python3/dist-packages/ogr.py", line 2, in <module>
from osgeo.gdal import deprecation_warn
File "/opt/pycharm-community-2018.1.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 19, in do_import
module = self._system_import(name, *args, **kwargs)
File "/opt/pycharm-community-2018.1.4/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 19, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/lib/python3/dist-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
File "/usr/lib/python3/dist-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/lib/libgdal.so.20: undefined symbol: _ZN11xercesc_3_111InputSource11setEncodingEPKt

For PyCharm I used Python 3.5.2.

Does someone has an idea?

Thank you very much!

Upvotes: 1

Views: 5776

Answers (1)

Rutger Kassies
Rutger Kassies

Reputation: 64463

If it worked yesterday, try looking at conda list --revisions -n gmt-python2 to see what changed since.

I don't think Anaconda itself comes with gdal from the conda-forge channel, and libgdal from the anaconda channel. So it must have happened at some point.

You could try forcing Conda to update using either one of the channels. With GDAL I definitely prefer the conda-forge build since it has (at least had in the past) better working activation scripts which also correctly set the GDAL_DATA environment variable when switching environments.

conda install conda-forge::gdal=2.2.4 --force --update-dependencies

Upvotes: 0

Related Questions