在 Ubuntu 20.04 上安装 libgdal-dev

在 Ubuntu 20.04 上安装 libgdal-dev

我正在尝试使用以下命令在 Ubuntu 20.04 上安装 GDAL 和 GDAL 开发库(来源: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 安装成功并返回:

GDAL 3.0.4, released 2020/01/28

之后,我尝试安装 GDAL 开发库:

sudo apt-get install libgdal-dev

它返回以下错误:

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.

这里有什么问题?我在某处读到“UbuntuGIS 稳定 ppa (launchpad.net/~ubuntugis/+archive/ubuntu/ppa) 没有任何 20.04 软件包。” 有解决方法吗?如果我在 Ubuntu 18.04 上尝试,一切都会正常。

答案1

您不需要为 ubuntu 20.04 添加 apt 存储库。只需执行以下操作:

  1. sudo apt update
  2. sudo apt install libpq-dev gdal-bin libgdal-dev

答案2

对我有用的解决方案如下

我尝试安装 libgdal-dev 但也出现以下错误:

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

我使用 aptitude 以交互方式解决依赖关系。您也可以使用仅aptitude在终端中运行的 GUI ncursis 版本。它会要求保留当前版本,选择n(否),它会告诉您下一步如何解决。在这种情况下,它建议降级软件包,选择“Y”,它将成功安装 libgdal-dev。

$ 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

现在只需检查运行sudo apt install libgdal-dev

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

希望这可以帮助!!

相关内容