I'm trying to install GDAL and GDAL development libraries on Ubuntu 20.04 with the following commands (source: ):
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install gdal-bin
ogrinfo --version GDAL installs successfully and it returns:
GDAL 3.0.4, released 2020/01/28After that, I tried installing GDAL development libraries:
sudo apt-get install libgdal-devIt returns the following error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies: libgdal-dev : Depends: libpq-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.What is the problem here? I read somewhere that "UbuntuGIS stable ppa () does not have any 20.04 packages." Is there a workaround for this? Everything works if I try it on Ubuntu 18.04.
22 Answers
You don't need to add apt repository for ubuntu 20.04. Just do:
sudo apt update.sudo apt install libpq-dev gdal-bin libgdal-dev
The Solution that worked for me is as follows
I was trying to install libgdal-dev and also had following error:
The following packages have unmet dependencies:
libgdal-dev : Depends: libarmadillo-dev but it is not going to be installed Depends: libdap-dev but it is not going to be installed Depends: libgeotiff-dev (>= 1.5.0) but it is not going to be installed Depends: libhdf4-alt-dev but it is not going to be installed Depends: libhdf5-dev but it is not going to be installed Depends: libkml-dev but it is not going to be installed Depends: liblzma-dev but it is not going to be installed Depends: default-libmysqlclient-dev but it is not going to be installed Depends: libnetcdf-dev but it is not going to be installed Depends: libpng-dev but it is not going to be installed Depends: libspatialite-dev but it is not going to be installed Depends: libtiff-dev but it is not going to be installedI have use aptitude to interactively resolve dependencies.
You can also use the GUI ncursis version only running aptitude in terminal.
It will ask to keep the current version, select n (No) and it will tell you how to resolve next. In this case it suggested downgrading packages, select 'Y' and it will install libgdal-dev successfully.
$ sudo aptitude install libgdal-dev
...
... Keep the following packages at their current version:
1) default-libmysqlclient-dev [Not Installed]
2) libarmadillo-dev [Not Installed]
3) libdap-dev [Not Installed]
4) libgdal-dev [Not Installed]
5) libgeotiff-dev [Not Installed]
6) libhdf4-alt-dev [Not Installed]
7) libhdf5-dev [Not Installed]
8) libkml-dev [Not Installed]
9) liblzma-dev [Not Installed]
10) libmysqlclient-dev [Not Installed]
11) libnetcdf-dev [Not Installed]
12) libpng-dev [Not Installed]
13) libspatialite-dev [Not Installed]
14) libtiff-dev [Not Installed]
15) uuid-dev [Not Installed]
16) zlib1g-dev [Not Installed]
Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies: Downgrade the following packages:
1) liblzma5 [5.2.4-1ubuntu1 (now) -> 5.2.4-1 (focal)]
2) libuuid1 [2.34-0.1ubuntu9.1 (now) -> 2.34-0.1ubuntu9 (focal)]
3) zlib1g [1:1.2.11.dfsg-2ubuntu1.2 (now) -> 1:1.2.11.dfsg-2ubuntu1 (focal)]
Accept this solution? [Y/n/q/?] YNow just to check run sudo apt install libgdal-dev
libgdal-dev is already the newest version (3.0.4+dfsg-1build3).Hope this helps!!