14

I'm trying to install GDAL on my Ubuntu 20.04 with the following commands:

sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update
sudo apt-get update
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev

After running the last line, I get 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?

5
  • 1
    UbuntuGIS stable ppa (launchpad.net/~ubuntugis/+archive/ubuntu/ppa) does not have any 20.04 packages. 20.04 has recent GDAL, remove the ppa and just sudo apt install gdal-bin
    – user2856
    Commented Aug 6, 2020 at 22:13
  • Ok, I removed ppa:ubuntugis/ppa and sudo apt install gdal-bin works, but it also worked before. The last line sudo apt-get install libgdal-dev returns the error I described in my question. Commented Aug 7, 2020 at 17:12
  • 1
    Reinstalling libpq-dev worked for me after moving to Ubuntu 20.04.
    – ataman
    Commented Sep 15, 2020 at 13:46
  • 1
    A complete removal (via synaptic) of libpq and libpq-dev including all depending packages and then reinstalling the package worked for me...
    – m13r
    Commented Jan 21, 2021 at 13:56
  • 1
    Please check out my answer askubuntu.com/a/1302161/981522
    – Mitch
    Commented Feb 13, 2021 at 9:15

4 Answers 4

5

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!!

0

You have to first install postgreSQL, which includes libpq*.

0

run these commands

sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install gdal-bin

these 2 command install dependencies for gdal libs

sudo apt install libpq5=12.10-0ubuntu0.20.04.1
sudo apt install libpq-dev

ogrinfo --version
sudo apt-get install libgdal-dev
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
pip install GDAL=='GDAL VERSION FROM OGRINFO'
-1

sudo apt-get install build-essential

then proceed with the installation

1
  • 1
    Just tried it and still getting the same error after: sudo apt-get install libgdal-dev Commented Sep 2, 2020 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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