My gdal libraries work properly with any other function used. However, using gdal_calc.py I run into troubles. I use gdal from the shell (linux) with this command:

gdal_calc.py -A /somepath/somefile.tif -B /somepath/somefile2.tif --outfile=/somepath/somefile3.tif --calc="A*B" --type UInt32 --overwrite

The error I get is:

Traceback (most recent call last):
  File "/usr/bin/gdal_calc.py", line 53, in <module>
  from osgeo import gdalnumeric
File "/usr/lib/python2.7/dist-packages/osgeo/gdalnumeric.py", line 1, in <module>
  from osgeo.gdal_array import *
  File "/usr/lib/python2.7/dist-packages/osgeo/gdal_array.py", line 28, in <module>
  _gdal_array = swig_import_helper()
File "/usr/lib/python2.7/dist-packages/osgeo/gdal_array.py", line 24, in swig_import_helper
_mod = imp.load_module('_gdal_array', fp, pathname, description)
ImportError: /usr/lib/python2.7/dist-packages/osgeo/_gdal_array.x86_64-linux-gnu.so: undefined symbol: GDALCreateDriver
  • Do you have the python-gdal package installed? How about libgdal-dev? – Marc Pfister Dec 8 '18 at 17:58
  • Yes, they are both installed. libgdal-dev is already the newest version (2.2.2+dfsg-1~xenial1) and python-gdal is already the newest version (2.2.2+dfsg-1~xenial1) – joaoal Dec 8 '18 at 19:31
  • 1
    Do you have more than one Python installed? Try which python? – Marc Pfister Dec 8 '18 at 20:11
  • If I put ẁhich python I get /usr/bin/python. However, if I have a manual look at the `usr/bin'' folder I see several pythons. It seems like I have python 2.7 and python 3.5 installed. In the above case. osgeo uses 2.7 it seems. – joaoal Dec 8 '18 at 20:29
  • Do you numpy installed in Python 2.7? – Marc Pfister Dec 8 '18 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.