本文介绍了在安装"sf"时遇到麻烦由于"gdal"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法在R上安装软件包"sf".似乎gdal存在问题.不知道如何解决它.
I can't install the package "sf" on R. Seems there is an issue with gdal. No idea how to resolve it.
> 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’
为什么说下载失败,然后说下载了源软件包.有什么作用?
Why does it say the download failed, then say the source packages are downloaded. What gives?
推荐答案
遇到类似的问题,我已经按照以下步骤操作:
Facing similar problem I have followed the steps below:
- 在端子上:
gdalinfo --version
检查您拥有的gdal版本.我的是 GDAL 2.2.0,于brew update
和brew upgrade
之后发布于2017/04/28 - 从这里开始: https://github.com/r-spatial/sf ,说明对于macOS,因为我已经安装了gdal,所以我只使用了
brew unlink gdal
,然后使用了brew link --force gdal2
- 我在R:
install.packages("rgdal", repos = "http://cran.us.r-project.org", type = "source")
上重新安装了rgdal,并且我确认它是使用配置:GDAL:2.2.0 编译的 - 最后,
install.packages("sf")
并且需要进行编译: binary source needs_compilation sf 0.5-3是 - 同样,我已经确认配置:GDAL:2.2.0 和正在检查GDAL版本> = 2.0.0 ...是
- On Terminal:
gdalinfo --version
to check which gdal version do you have. Mine was GDAL 2.2.0, released 2017/04/28 afterbrew update
andbrew upgrade
- From here: https://github.com/r-spatial/sf, instructions for macOS, as I have already gdal installed, I have used only
brew unlink gdal
and thenbrew link --force gdal2
- I reinstalled rgdal on R:
install.packages("rgdal", repos = "http://cran.us.r-project.org", type = "source")
and I have confirmed it was compiled with configure: GDAL: 2.2.0 - Finally,
install.packages("sf")
and it required to be compiled: binary source needs_compilation sf 0.5-3 TRUE - Again, I have confirmed configure: GDAL: 2.2.0 and checking GDAL version >= 2.0.0... yes
之后,我安装了新版本:图书馆(科幻小说)链接到GEOS 3.6.2,GDAL 2.2.0,proj.4 4.9.3
After that, I have the new version installed:library(sf)Linking to GEOS 3.6.2, GDAL 2.2.0, proj.4 4.9.3
我希望它也可以为您提供解决方案.
I hope it could be a solution for you too.
这篇关于在安装"sf"时遇到麻烦由于"gdal"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!