簡體   English   中英

錯誤:安裝 R 依賴包時找不到 gdal-config 而安裝了 gdal

[英]Error: gdal-config not found while installing R dependent packages whereas gdal is installed

請指出我遺漏的一點:

openSUSE 11.3


xx@linux-y3pi:~/Desktop/R> sudo R CMD INSTALL rgdal_0.7-12.tar.gz 
root's password:
* installing to library ‘/usr/lib64/R/library’
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: gdal-config: gdal-config
checking gdal-config usability... ./configure: line 1353: gdal-config: command not found
no
Error: gdal-config not found
The gdal-config script distributed with GDAL could not be found.
If you have not installed the GDAL libraries, you can
download the source from  http://www.gdal.org/
If you have installed the GDAL libraries, then make sure that
gdal-config is in your path. Try typing gdal-config at a
shell prompt and see if it runs. If not, use:
 --configure-args='--with-gdal-config=/usr/local/bin/gdal-config'
with appropriate values for your installation.

ERROR: configuration failed for package ‘rgdal’
* removing ‘/usr/lib64/R/library/rgdal’

xx@linux-y3pi:~/Desktop/R> whereis gdal-config
gdal-config: /usr/local/bin/gdal-config

xx@linux-y3pi:~/Desktop/R> gdal-config 
Usage: gdal-config [OPTIONS]
Options:
 [--prefix[=DIR]]
 [--libs]
 [--dep-libs]
 [--cflags]
 [--datadir]
 [--version]
 [--ogr-enabled]
 [--formats]
 xx@linux-y3pi:~/Desktop/R>

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
> 

xx@linux-y3pi:~/Desktop/R> gdal-config --version
1.9.0

xx@linux-y3pi:~/Desktop/R> proj
Rel. 4.8.0, 6 March 2012
usage: proj [ -beEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ]

linux-y3pi:~ # $PATH
bash: /home/xx/qtsdk-2010.05/qt/bin/:/home/xx/qtsdk-2010.05/bin:/home/xx/qtsdk-2010.05/qt/bin:/home/xx/qtsdk-2010.05/qt/bin/:/home/xx/qtsdk-2010.05/bin:/usr/lib64/mpi/gcc/openmpi/bin:/home/xx/bin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games: No such file or directory

在 Ubuntu 18.04 中

我通過sudo apt install libgdal-dev修復了這個問題希望有人覺得這有幫助。 上面的一些答案似乎已經過時且冗長。

在早期版本中(有 apt-get)

sudo apt-get install libgdal-dev

除了用於部署的普通包之外,您還需要帶有頭文件和共享庫鏈接的-dev包用於開發 就發行版而言,有兩種不同的用例。

在我的發行版中:

edd@max:/tmp$ dpkg -l | grep gdal | cut -c-72
ii  libgdal1-1.7.0                                1.7.3-6ubuntu3        
ii  libgdal1-dev                                  1.7.3-6ubuntu3        
edd@max:/tmp$ 

R CMD INSTALL rgdal_0.7-8.tar.gz工作得很好,就像你對 CRAN 包所期望的那樣,考慮到 CRAN 的所有構建時檢查。

2016 年末更新:正如@JoshO'Brien 在評論中指出的那樣

小更新:在 2016 年,運行 Ubuntu 14.04.2, libgdal1h似乎已經取代了libgdal1 (盡管仍然需要libgdal1-dev )。 至少當我嘗試apt-get install libgdal1時,我得到了一個錯誤

對於 Ubuntu 16.04,相應的行是
sudo apt-get install libgdal1i

上游庫的這種重命名很常見; 諸如apt-cache search libgdal可以幫助定位當前的包名稱。 不過,重要的關鍵是“抽象”開發包libgdal-dev是構建所需的全部,因為它通過依賴項拉入“具體”當前運行時包(此處: libgdal1i )。

您可以使用apt-file包來查找包含您要查找的丟失文件的包。

首先使用命令安裝的apt-文件apt-get install apt-file
使用命令升級apt-文件apt-file update
現在您可以使用apt-file來查找丟失的文件。 apt-file search gdal-config

就我而言,從 svn 配置grass-7.1 時我遇到了同樣的錯誤。 如下所示:

    $ ./configure
    ...more...
    checking whether to use GDAL... yes
    checking for gdal-config... /usr/bin/gdal-config
                  ...more....
    ./configure: 1: ./configure: /usr/bin/gdal-config: not found
    ./configure: 6093: test: =: unexpected operator
    configure: error: *** Unable to locate GDAL library.

但是,在使用apt-file查找gdal-config文件后,如下所示,在安裝軟件包libgdal1-dev后,我能夠解決該錯誤

$ apt-file search gdal-config

結果

libgdal1-dev: /usr/bin/gdal-config

所以我安裝了libgdal1-dev ,如下圖:

$ sudo apt-get install libgdal1-dev

發生這種情況是因為包“rgdal”的配置失敗,因此我們必須安裝必要的依賴項。

需要軟件包 libgdal-dev 和 libproj-dev:

sudo apt-get install gdal-bin proj-bin libgdal-dev libproj-dev

然后通過安裝 rgdal

install.packages("rgdal")

加載 rgdal

library(rgdal)

macOS 上

brew install gdal

刪除了錯誤

找不到 gdal-config

在 CentOS 6 上試試這個

sudo yum install gdal gdal-python gdal-devel mapserver mapserver-python libxml2 libxml2-python python-lxml python-pip python-devel gcc

閱讀參考手冊。

從源代碼構建的系統要求:來自http://trac.osgeo.org/gdal/wiki/DownloadSource 的GDAL >= 1.6.0 庫和來自http://trac.osgeo 的PROJ.4 (proj >= 4.4.9) 。組織/項目/

今天我在 Linux CentOS 6.10 上發生了同樣的問題,我沒有管理權限。

我做了什么:

a) 創建專用於我的 R 版本的 conda 環境

conda create --name MYR

b) 激活環境

source activate MYR

c) 安裝 R

conda install -c conda-forge r-base

d) 安裝 libgdal

conda install -c conda-forge libgdal

這為我解決了問題。 我的 R 版本是 4.1.3。 我想其他版本應該可以。

對於 manjora 或 archlinux,只需嘗試: yay -S gdal

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM