10

I'm trying to install GDAL and GDAL development libraries on Ubuntu 20.04 with the following commands (source: https://mothergeo-py.readthedocs.io/en/latest/development/how-to/gdal-ubuntu-pkg.html):

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/28

After that, I tried installing GDAL development libraries:

sudo apt-get install libgdal-dev

It 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 (launchpad.net/~ubuntugis/+archive/ubuntu/ppa) does not have any 20.04 packages." Is there a workaround for this? Everything works if I try it on Ubuntu 18.04.

2
  • Tried solutions from both links and it still doesn't work. Commented Aug 17, 2020 at 10:08
  • 1
    Sorry, I shouldn't have cast the final close vote here, as you commented that neither of the proposed questions helped. I have voted to reopen it. I also thought this needed more details to answer, but I may have been wrong about that too: expanding the "Published in" drop-down menu at launchpad.net/~ubuntugis/+archive/ubuntu/ppa confirms the PPA you're using doesn't have 20.04 packages. So this is likely answerable. Although it may be helpful if you were to edit it to include details about all the solutions you tried and what happened, this can be reopened at any time. Sorry again! Commented Aug 17, 2020 at 18:46

2 Answers 2

17

You don't need to add apt repository for ubuntu 20.04. Just do:

  1. sudo apt update.
  2. sudo apt install libpq-dev gdal-bin libgdal-dev
2
  • 3
    Seems to work fine now with: sudo aptitude install gdal-bin libgdal-dev Commented May 17, 2021 at 12:07
  • seems it also worked on my ubuntu 18.04
    – DarkCygnus
    Commented Mar 22, 2022 at 22:46
3

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 installed

I 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/?] Y

Now just to check run sudo apt install libgdal-dev

libgdal-dev is already the newest version (3.0.4+dfsg-1build3).

Hope this helps!!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .