当我尝试使用以下命令安装 postgis 时:
sudo apt install postgresql-12-postgis-2.5
我遇到了一个错误:
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.
然后,当我尝试安装 libgdal20 时,我遇到了更多依赖问题
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.
有人可以指导我如何正确安装 postgis 吗?
更新
这是我的结果sudo apt update
。后面跟着很多行警告,如下所示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.
答案1
首先删除现有的存储库,您有一个来自 Bionic 的存储库,这就是导致问题的根源。假设它位于/etc/apt/sources.list.d/pgdg.list
。
sudo rm /etc/apt/sources.list.d/pgdg.list
现在为您的系统添加正确的存储库。
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
答案2
Lido 的答案也帮助我在 Ubuntu 18(带有 PostgreSQL 10)上安装了 Postgis,但我必须从 Debian 存储库安装软件包 libjson-c4 和 libgcc-s1