如何在 MacOS 上下载 Sf 包
How to download Sf package on MacOS
我尝试了几个小时来使用我在网上遇到的大多数解决方案来安装 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。为此,我先安装了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[=52= 中的解决方案].
然而,在第 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,我将非常高兴。
错误消息行“Warning in install.packages : downloaded length 68510897 != reported length 93022013”和“Timeout of 60 seconds was reached”表明包没有正确下载 - 这可能发生在需要超过 60 秒才能将软件包下载到您的计算机进行安装,即达到 60 秒的“超时”。
一个解决方案(在这种情况下有效的解决方案)是在 运行 [=11 之前将 R 等待下载包的时间增加 运行 options(timeout = 1200)
=]
如果您需要在 M1 mac 上从源代码(使用或不使用 openMP)构建软件包,我相信此处发布的说明有效:
我尝试了几个小时来使用我在网上遇到的大多数解决方案来安装 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。为此,我先安装了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[=52= 中的解决方案].
然而,在第 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,我将非常高兴。
错误消息行“Warning in install.packages : downloaded length 68510897 != reported length 93022013”和“Timeout of 60 seconds was reached”表明包没有正确下载 - 这可能发生在需要超过 60 秒才能将软件包下载到您的计算机进行安装,即达到 60 秒的“超时”。
一个解决方案(在这种情况下有效的解决方案)是在 运行 [=11 之前将 R 等待下载包的时间增加 运行 options(timeout = 1200)
=]
如果您需要在 M1 mac 上从源代码(使用或不使用 openMP)构建软件包,我相信此处发布的说明有效: