我尝试了几个小时来安装sf软件包(在MacOs上),使用了我在网络上遇到的大多数解决方案,但仍然没有工作。让我展示一下,我做了什么,然后问题是什么是一步一步的。
首先,我尝试了正常的事情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中的指示。为此,我首先安装了home brew
,然后在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, released 2021/09/01
,第二,我运行了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,我会很高兴的。
发布于 2021-09-18 04:46:17
错误消息行“install.packages中的警告:下载长度68510897 !=报告长度为93022013”和“到达60秒的超时”表明包没有正确下载--如果将包下载到计算机安装所需的时间超过60秒,即达到60秒的“超时”,就会发生这种情况。
一种解决方案(在本例中起作用的解决方案)是在运行options(timeout = 1200)
之前增加R等待通过运行install.packages("sf")
下载包的时间
如果您需要在openMP mac上从源代码(包括或不带M1 )构建包,我相信这里发布的说明是有效的:https://stackoverflow.com/a/68275558/12957340
发布于 2022-08-08 18:01:10
不确定这是否有帮助,但我也遇到了类似的麻烦,把它安装在一个新鲜的Mac上。最后,我安装了XQuartz (我还没有),下载了自制软件来获得PROJ,然后重新安装了R (50/50,关于我是否下载了M1 Mac的正确版本),并将所有的东西都安装好了。
https://stackoverflow.com/questions/69230615
复制相似问题