5

I've been having a lot of problems with this install, especially with various unmet dependencies. these are my system infos:

Linux

  • Ubuntu 20.04.4 LTS
  • 64-bit
  • Gnome_Version: 3.36.8

Python

  • using a "poetry environment" (uses pip)
  • python Version: 3.8.10
John Lloyd
  • 157
  • 1
  • 11

2 Answers2

9

I was finally able to install it more or less cleanly and get it working across the board and hope it will be usefull for others:

Installing GDAL on linux is full of problems and issues - this has resolved some of them for me:


sudo apt install libpq-dev

  • problem depedency with libpq5

sudo apt install libpq5=12.2-4

sudo apt install libpq-dev

  • success!

sudo apt install gdal-bin

sudo apt install libgdal-dev

  • problem with LOTS of dependencies

sudo apt install aptitude

  • (aptitude can help resolve dependency problems)

sudo aptitude install libgdal-dev

  • asks how to resolve issues --> I changed to next reccomendation by pressing "." --> then confirmed by pressing "Y" -->success



after these steps are successfull check if all 3 main libs are installed: "libpq-dev, gdal-bin, libgdal-dev":

apt list --installed | grep "gdal"

result:


WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

gdal-bin/focal,now 3.3.2+dfsg-2~focal2 amd64 [installed]
gdal-data/focal,focal,now 3.3.2+dfsg-2~focal2 all [installed,automatic]
libgdal-dev/focal,now 3.3.2+dfsg-2~focal2 amd64 [installed]
libgdal29/focal,now 3.3.2+dfsg-2~focal2 amd64 [installed,automatic]
python3-gdal/focal,now 3.3.2+dfsg-2~focal2 amd64 [installed,automatic]

check gdal version (should be 3.3.2 or higher if all went well):

gdalinfo --version

PYTHON

to install gdal in a python environment should now be possible:

poetry add gdal==3.3.0

or

pip install gdal==3.3.0




by john, this worked 06.07.2022

Griffith Rees
  • 1,285
  • 2
  • 15
  • 24
John Lloyd
  • 157
  • 1
  • 11
  • Thank you, I got an error during installation of wradlib that caused by gdal. Now it works for me. Don't forget to accept your answer :) – muchtarsp Aug 12 '22 at 10:33
  • Were you using any special repo? When I run `apt list --installed | grep "gdal"` I don't get the same versions as you, and I am indeed using Ubuntu 20.04 Focal. E.g. first line is: `gdal-bin/focal,now 3.0.4+dfsg-1build3 amd64 [installed]`, and the rest are the same 3.0.4. – José L. Patiño Aug 26 '22 at 14:41
  • 1
    I'm on Apple M1 / Silicon, building a linux-based docker image. In case someone else happens upon this and it may help them, I needed to use apt/apt-get to install `gdal-bin` and `libgdal-dev` as the only prerequisites to the python package(s) – rkechols Feb 27 '23 at 22:43
0

This is an add-on to the previous answer, for those who need to compile the source code of a gdal version :

start with https://gdal.org/development/dev_environment.html then https://gdal.org/development/building_from_source.html

It says that the minimum requirements to build GDAL are:

  • CMake >= 3.10, and an associated build system (make, ninja, Visual Studio, etc.)
  • C99 compiler
  • C++11 compiler
sudo apt update && sudo apt upgrade && sudo apt install build-essential
  • PROJ >= 6.0

PROJ needs the following dependencies :

sudo apt-get install sqlite3
sudo apt-get install libsqlite3-dev
sudo apt-get install libtiff5-dev
sudo apt-get install curl
sudo apt-get install libcurl4-openssl-dev

Download source code of osgeo/PROJ (tar.gz) and build with the same procedure than for GDAL:

tar -xvzf proj-9.2.1.tar.gz proj-9.2.1/
cd proj-9.2.1/
mkdir build
cd build
cmake ..
cmake --build .
sudo cmake --build . --target install

Download source code of osgeo/GDAL (tar.gz -> https://github.com/OSGeo/gdal/releases) and build: It is necessary to install libgdal-dev

sudo apt-get -y install libgdal-dev

tar -xvzf gdal-3.7.0.tar.gz 
cd gdal-3.7.0/
mkdir build
cd build/
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --build . --target install
vpa
  • 341
  • 1
  • 2
  • 8