0

I asked this question before realising this site existed:

https://stackoverflow.com/questions/51476826/gdal-2-3-1-is-installed-but-the-llinux-terminal-is-using-gdal-2-2-2

I've installed GDAL 2.3.1 using pip on a ubuntu 16.04 in a python environment. The package is in the correct site-packages directory and yet when I run a python script, I receive this error:

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

The error then ends in a segmentation fault (core dumped).

When using gdal-config --version, the output shows 2.2.2.

I want to know how to change the version of gdal that linux appears to be using from 2.2.2 to 2.3.1 but I have no idea how to do this.

UPDATE

As asked, here's the method I used to install gdal and the outputs. I followed the method in Python GDAL package missing header file when installing via pip

I installed it in a python environment built to be able to run tensorflow 1.8.0 with Cuda 9.2 using a GPU - I don't know if that makes any difference

COMMAND

sudo apt-get install libgdal-dev

OUTPUT

Reading package lists... Building dependency tree... Reading state information... Suggested packages: libgdal-doc The following NEW packages will be installed: libgdal-dev 0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded. Need to get 0 B/6,496 kB of archives. After this operation, 40.1 MB of additional disk space will be used. Selecting previously unselected package libgdal-dev. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 233309 files and directories currently installed.) Preparing to unpack .../libgdal-dev_2.2.2+dfsg-1~xenial1_amd64.deb ... Unpacking libgdal-dev (2.2.2+dfsg-1~xenial1) ... Processing triggers for man-db (2.7.5-1) ... Setting up libgdal-dev (2.2.2+dfsg-1~xenial1) ...

COMMAND

export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal

pip install gdal

OUTPUT

Collecting gdal Installing collected packages: gdal Successfully installed gdal-2.3.1

Could it be something to do with libgdal-dev installing 2.2.2?

  • Yes, you're compiling the python bindings against the gdal 2.2.2 source. Either download the gdal 2.3 source (I haven't bothered doing this for years) or just install a pre-compiled version from the conda-forge channel using a conda env - conda create -n gdal23 -c conda-forge "gdal>=2.3" then source activate gdal23 – user2856 Jul 27 '18 at 1:40
  • Thanks, I tried doing that but now I have this error: ImportError: /home/conor/miniconda3/envs/gdal23/lib/python3.6/site- packages/osgeo/../../../libgdal.so.20: undefined symbol: sqlite3_column_table_name Is this caused by a previous installation of gdal? I tried removing duplicates of libgdal.so.20 but this has been ineffective – Conor Jul 27 '18 at 12:49
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

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.