0

When running my Python program, the following error came out:

ERROR 1: NUMPY driver was compiled against GDAL 2.1, but the current library version is 2.2

What can I do to fix this?

1

From the GDAL Python gotchas:

Python crashes in GDAL functions when you upgrade or downgrade numpy

Much of GDAL's Python bindings are implemented in C++. Much of the core of numpy is implemented in C. The C++ part of GDAL's Python bindings interacts with the C part of numpy through numpy's ABI (application binary interface). This requires GDAL's Python bindings to be compiled using numpy header files that define numpy C data structures. Those data structures sometimes change between numpy versions. When this happens, the new version of numpy is not be compatible at the binary level with the old version, and the GDAL Python bindings must be recompiled before they will work with the new verison of numpy. And when they are recompiled, they probably won't work with the old version.

If you obtain a precompiled version of GDAL's Python bindings, such as the Windows packages from ​http://vbkto.dyndns.org/sdk/, be sure you look up what version of numpy was used to compile them, and install that version of numpy on your machine.

So you either need to downgrade gdal to 2.1 or recompile the gdal python bindings against the new numpy headers.

0

In ubuntu, a simpler solution to install the latest gdal for python3: install library files via libgdal-dev, and python wrapper via python-gdal

sudo apt-get install libgdal-dev
sudo apt-get install python3-gdal

for python2:

sudo apt-get install python-gdal

this works for me fine

Your Answer

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

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