gpt4 book ai didi

r - 如何在MacOS上下载Sf包

转载 作者:行者123 更新时间:2023-12-03 08:16:32 41 4
gpt4 key购买 nike

我尝试了几个小时,使用我在网上遇到的大多数解决方案来安装 sf 软件包(在 MacO 上),但仍然不起作用。让我一步步展示我做了什么以及问题所在。

首先,我尝试了正常的 install.packages("sf") ,结果出现以下错误。

URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/sf_1.0-2.tgz' deneniyor
Content type 'application/x-gzip' length 93022013 bytes (88.7 MB)
====================================
downloaded 65.3 MB

Warning in install.packages :
downloaded length 68510897 != reported length 93022013
Warning in install.packages :
URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/sf_1.0-2.tgz': Timeout of 60 seconds was reached
Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'https://cran.rstudio.com/bin/macosx/contrib/4.1/sf_1.0-2.tgz' failed
Warning in install.packages :
download of package ‘sf’ failed

随后,我尝试遵守此网站 https://github.com/r-spatial/sf 中的说明。 。为此,我首先安装了 homebrew,然后在 MacOS 终端上渲染了这两个代码。

brew install pkg-config 
brew install gdal

最后,根据网站的建议,我运行此代码来安装 rgdal 包以安装 sf

install.packages("rgdal", configure.args = c("--with-proj-lib=/usr/local/lib/", "--with-proj-include=/usr/local/include/"))

但是,它出现了以下错误。

  There is a binary version available but the source version is later:
binary source needs_compilation
rgdal 1.5-26 1.5-27 TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘rgdal’

URL 'https://cran.rstudio.com/src/contrib/rgdal_1.5-27.tar.gz' deneniyor
Content type 'application/x-gzip' length 4391149 bytes (4.2 MB)
==================================================
downloaded 4.2 MB

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
** using staged installation
configure: R_HOME: /Library/Frameworks/R.framework/Resources
configure: CC: clang -mmacosx-version-min=10.13
configure: CXX: clang++ -mmacosx-version-min=10.13 -std=gnu++14
configure: CFLAGS: -Wall -g -O2
configure: CPPFLAGS: -I/usr/local/include
configure: CXXFLAGS: -Wall -g -O2
configure: LDFLAGS: -L/usr/local/lib
configure: LDFLAGS: -L/usr/local/lib
configure: CXX11 is: clang++ -mmacosx-version-min=10.13, CXX11STD is: -std=gnu++11
configure: CXX is: clang++ -mmacosx-version-min=10.13 -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.5-27
checking for /usr/bin/svnversion... no
configure: svn revision: 1148
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rgdal’
Warning in install.packages :
installation of package ‘rgdal’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/tc/g15hmz9s0hg1nxmh7_4mw9lm0000gn/T/RtmplfPV9h/downloaded_packages’

按照本网站的建议https://github.com/r-spatial/sf ,我或者尝试了 https://github.com/r-spatial/sf/issues/1536#issuecomment-727342736 中的解决方案.

但是,在第 2 部分中,当我运行此代码块时,

install.packages("rgeos", repos="http://R-Forge.R-project.org", type="source")
install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source")
library(devtools)
install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local/lib/")

所有这些代码都出现了类似的问题。例如,对于第一个,错误是;

URL 'http://R-Forge.R-project.org/src/contrib/rgeos_0.5-8.tar.gz' deneniyor
Content type 'application/x-gzip' length 276303 bytes (269 KB)
==================================================
downloaded 269 KB

* installing *source* package ‘rgeos’ ...
** using staged installation
configure: CC: clang -mmacosx-version-min=10.13
configure: CXX: clang++ -mmacosx-version-min=10.13 -std=gnu++14
configure: rgeos: 0.5-7
checking for /usr/bin/svnversion... no
cat: inst/SVN_VERSION: No such file or directory
configure: svn revision:
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rgeos’
Warning in install.packages :
installation of package ‘rgeos’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/tc/g15hmz9s0hg1nxmh7_4mw9lm0000gn/T/RtmplfPV9h/downloaded_packages’

最后,我按照该网站上的说明解决了这个问题; trouble installing "sf" due to "gdal"

首先:gdalinfo --version 代码生成了 GDAL 3.3.2,于 2021 年 9 月 1 日发布其次,我确实brew unlink gdal,但是当我运行brew link --force gdal2时,它不起作用。 (我是一个新用户,所以我认为这可能是因为版本不同,但是当我尝试 brew link --force gdal3.3.2 时,它给了我错误 Error: No such keg:/opt/homebrew/Cellar/gdal3.3.2

所以,如果您能帮助我如何在 MacOS 上安装 sf,我将非常高兴。

最佳答案

错误消息行“Install.packages 中的警告:下载长度 68510897 != 报告长度 93022013”​​和“已达到 60 秒超时”表明软件包未正确下载 - 当下载时间超过 60 秒时,可能会发生这种情况将软件包下载到您的计算机进行安装所需的秒数,即达到 60 秒的“超时”。

一种解决方案(在本例中有效的解决方案)是通过在运行 install 之前运行 options(timeout = 1200) 来增加 R 等待下载包的时间。包(“sf”)

如果您需要在 M1 mac 上从源代码(带或不带 openMP)构建软件包,我相信此处发布的说明有效:https://stackoverflow.com/a/68275558/12957340

关于r - 如何在MacOS上下载Sf包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69230615/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com