繁体   English   中英

由于“gdal”而无法安装“sf”

[英]trouble installing "sf" due to "gdal"

我无法在 R 上安装包“sf”。似乎 gdal 有问题。 不知道如何解决它。

> install.packages("sf")

  There is a binary version available but the source version is later:
   binary source needs_compilation
sf  0.4-3  0.5-1              TRUE

Do you want to install from sources the package which needs compilation?
y/n: y
installing the source package ‘sf’

trying URL 'https://cran.rstudio.com/src/contrib/sf_0.5-1.tar.gz'
Content type 'application/x-gzip' length 4073881 bytes (3.9 MB)
==================================================
downloaded 3.9 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
configure: CC: clang
configure: CXX: clang++
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/1m/w_zt5ygd26n_87h41qf574wc0000gn/T/RtmpNlYbwT/downloaded_packages’

为什么说下载失败,然后说下载了源码包。 是什么赋予了?

面对类似的问题,我已按照以下步骤操作:

  1. 终端上gdalinfo --version检查您拥有哪个 gdal 版本。 我的是GDAL 2.2.0,brew updatebrew upgrade后于brew update发布
  2. 从这里: https://github.com/r-spatial/sf ,macOS 说明,因为我已经安装了 gdal,我只使用了brew unlink gdal然后brew link --force gdal2
  3. 我在 R: install.packages("rgdal", repos = "http://cran.us.r-project.org", type = "source")上重新安装了 rgdal,我已经确认它是用configure: GDAL编译的: 2.2.0
  4. 最后, install.packages("sf")并且它需要被编译: binary source needs_compilation sf 0.5-3 TRUE
  5. 再次,我已经确认配置:GDAL:2.2.0检查 GDAL 版本 >= 2.0.0...是的

之后,我安装了新版本: library(sf) Linking to GEOS 3.6.2, GDAL 2.2.0, proj.4 4.9.3

我希望它也可以成为您的解决方案。

sf github 页面有安装说明,其中包含有关此问题的一些信息。 除了按照那里的步骤使用 brew 安装 gdal 之外,我还必须单独安装 proj:

https://github.com/r-spatial/sf

其实一个简单的解决方法是从 CRAN 下载 sf 文件,然后手动安装它。

我有同样的问题并使用这种方法解决了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM