Python gdal undefined symbol GDALRasterBandGetVirtualMem
I am trying to use Python GDAL bindings . When naively installing bindings via pip, the installation fails : "VSIFTruncateL" was not declared in this scope , probably due to a mismatch between the installed headers and version of python bindings, the suggested solution elsewhere is to install the same version via pip. However my system has gdal-1.7.3
, and there are no bindings of 1.7.3. Installing 1.7.1 bindings results in successful compilation, but attempting to execute results in undefined symbol: GDALRasterBandGetVirtualMem
. So I installed 1.11.1 from source and compiled the latest bindings to it. Compilation and installation seems to work, but the import fails:
In [2]: import osgeo
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-26b16a6d02ad> in <module>()
----> 1 import osgeo
/export/data/home/gholl/venv/gerrit/lib/python3.4/site-packages/osgeo/__init__.py in <module>()
19 fp.close()
20 return _mod
---> 21 _gdal = swig_import_helper()
22 del swig_import_helper
23 else:
/export/data/home/gholl/venv/gerrit/lib/python3.4/site-packages/osgeo/__init__.py in swig_import_helper()
15 if fp is not None:
16 try:
---> 17 _mod = imp.load_module('_gdal', fp, pathname, description)
18 finally:
19 fp.close()
/export/data/home/gholl/venv/gerrit/lib64/python3.4/imp.py in load_module(name, file, filename, details)
241 return load_dynamic(name, filename, opened_file)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
245 return load_package(name, filename)
ImportError: /export/data/home/gholl/venv/gerrit/lib/python3.4/site-packages/osgeo/_gdal.cpython-34m.so: undefined symbol: GDALRasterBandGetVirtualMem
Now I'm at a loss. What else can I try to use gdal
and its Python bindings?
(A system Scientific Linux release 6.6 (Carbon)
on which I do not have system administrator access.)
source to share
If the version of gdal is already installed, this issue will occur even if you are linked to the version installed in ~/.local
.
The solution is given in the planet MYSQL post here :
In this case, we can tell the linker to preload our new 1.11.0 library into our wrapper like this:
export LD_PRELOAD=/usr/local/lib/libgdal.so.1
Or, in my case,
export LD_PRELOAD="$HOME/.local/lib/libgdal.so.1"
Indeed, this solves the problem.
source to share