添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange

Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.

Sign up to join this community

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I run into an error:

The following packages have unmet dependencies:
 postgresql-12-postgis-2.5 : Depends: libgdal20 (>= 2.0.1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Then when I try to install libgdal20, I run into more dependency issues

The following packages have unmet dependencies:
 libgdal20 : Depends: gdal-data (>= 2.2.3+dfsg-2) but it is not going to be installed
             Depends: libhdf5-100 but it is not going to be installed
             Depends: libnetcdf13 (>= 4.0.1) but it is not going to be installed
             Depends: libogdi3.2 (>= 3.2.0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Can someone guide me through the correct way to install postgis?

Update

This is the result of my sudo apt update. It is followed by a lot of lines of warning that look like this Target .... is configured multiple times in /etc/apt/sources.list:53 and /etc/apt/sources.list:

$>sudo apt-get update
Hit:1 http://fr.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://fr.archive.ubuntu.com/ubuntu focal-updates InRelease                                                      
Hit:3 http://fr.archive.ubuntu.com/ubuntu focal-backports InRelease                                                    
Hit:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease                                                   
Hit:5 http://archive.ubuntu.com/ubuntu bionic InRelease                                                                
Hit:6 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease                                                    
Hit:7 http://archive.ubuntu.com/ubuntu bionic-security InRelease                                                       
Hit:8 http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu focal InRelease                                     
Hit:9 http://archive.ubuntu.com/ubuntu bionic-updates InRelease                                                        
Ign:10 http://apt.postgresql.org/pub/repos/apt bionioc-pgdg InRelease                                                  
Hit:11 http://apt.postgresql.org/pub/repos/apt trusty-pgdg InRelease                                                   
Err:12 http://apt.postgresql.org/pub/repos/apt bionioc-pgdg Release                                                    
  404  Not Found [IP: 147.75.85.69 80]
Hit:13 https://packages.cloud.google.com/apt cloud-sdk InRelease                          
Hit:14 http://us.archive.ubuntu.com/ubuntu bionic InRelease                               
Hit:15 http://security.ubuntu.com/ubuntu focal-security InRelease   
Hit:16 http://us.archive.ubuntu.com/ubuntu bionic-security InRelease
Hit:17 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Ign:18 https://artifacts.elastic.co/packages/5.x/apt stable InRelease
Hit:19 https://artifacts.elastic.co/packages/5.x/apt stable Release
Reading package lists... Done
E: The repository 'http://apt.postgresql.org/pub/repos/apt bionioc-pgdg Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Remove the existing repository first, you had the one from Bionic, that's what causing the problem to begin with. Assuming it is resided on /etc/apt/sources.list.d/pgdg.list.

sudo rm /etc/apt/sources.list.d/pgdg.list

Now add the correct repository for your system.

echo "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt install postgresql-12-postgis-2.5
                You are awesome! I deleted in my /etc/apt/sources,list files all references to postgresql and added the one you gave me. It works like magic!
– Chiney
                May 12, 2020 at 2:35
                good to know. I always thought ubuntu does nice, with postgres/upgrades/etc. Until I lingered on ps11 for too long, and now postgresql-11-postgis-2.5 was no longer available. after switching sources, I could finally pg_upgradecluster
– benzkji
                Aug 22, 2020 at 23:02
                This is rather a comment, not an answer to the question (there were unmet dependencies which you did not address). So if you can't comment, wait until you have enough reputation to to so.
– kanehekili
                Jul 3, 2020 at 22:42