[英]Cannot install "raster" package in R
我正在尝试在 R 中使用光栅 package,但自从我买了一台新计算机并在 macOS 上安装了最新版本的 R 后,它提到某些软件包不适用于此版本的 R。
我尝试直接在 R studio 上下载 R,但出现错误。
接下来我尝试使用以下命令直接从 GitHUB 安装:
install.packages('raster', repos='https://rspatial.r-universe.dev')
这是我收到的错误消息:
Installing package into ‘/Users/username/Library/R/arm64/4.2/library’
(as ‘lib’ is unspecified)
also installing the dependency ‘terra’
Packages which are only available in source form, and may need compilation of
C/C++/Fortran: ‘terra’ ‘raster’
Do you want to attempt to install these from sources? (Yes/no/cancel) yes
installing the source packages ‘terra’, ‘raster’
trying URL 'https://rspatial.r-universe.dev/src/contrib/terra_1.6-43.tar.gz'
Content type 'application/x-gzip' length 1777090 bytes (1.7 MB)
==================================================
downloaded 1.7 MB
trying URL 'https://rspatial.r-universe.dev/src/contrib/raster_3.6-6.tar.gz'
Content type 'application/x-gzip' length 1310884 bytes (1.3 MB)
==================================================
downloaded 1.3 MB
* installing *source* package ‘terra’ ...
** using staged installation
configure: CC: clang -arch arm64
configure: CXX: clang++ -arch arm64 -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘terra’
* removing ‘/Users/username/Library/R/arm64/4.2/library/terra’
Warning in install.packages :
installation of package ‘terra’ had non-zero exit status
ERROR: dependency ‘terra’ is not available for package ‘raster’
* removing ‘/Users/username/Library/R/arm64/4.2/library/raster’
Warning in install.packages :
installation of package ‘raster’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/zp/vysqcnr95g5d08jhlmzrvj9m0000gn/T/Rtmpn4J6eA/downloaded_packages’
当我接下来加载光栅时,这就是我所看到的:
library(raster)
#Error: package or namespace load failed for ‘raster’ in #loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
# there is no package called ‘terra’
当我尝试安装 Terra 时,这是我看到的错误消息:
> install.packages('terra')
Installing package into ‘/Users/sofigreen/Library/R/arm64/4.2/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/terra_1.6-41.tgz'
Content type 'application/x-gzip' length 99009623 bytes (94.4 MB)
===============
downloaded 28.7 MB
Warning in install.packages :
downloaded length 30079735 != reported length 99009623
Warning in install.packages :
URL 'http://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/terra_1.6-41.tgz': status was 'Failure when receiving data from the peer'
Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'http://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/terra_1.6-41.tgz' failed
Warning in install.packages :
download of package ‘terra’ failed
当尝试从源代码下载 terra 时:
> install.packages('terra', repos='https://rspatial.r-universe.dev')
Installing package into ‘/Users/username/Library/R/arm64/4.2/library’
(as ‘lib’ is unspecified)
Package which is only available in source form, and may need compilation of
C/C++/Fortran: ‘terra’
Do you want to attempt to install these from sources? (Yes/no/cancel) yes
installing the source package ‘terra’
trying URL 'https://rspatial.r-universe.dev/src/contrib/terra_1.6-43.tar.gz'
Content type 'application/x-gzip' length 1786823 bytes (1.7 MB)
==================================================
downloaded 1.7 MB
* installing *source* package ‘terra’ ...
** using staged installation
configure: CC: clang -arch arm64
configure: CXX: clang++ -arch arm64 -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘terra’
* removing ‘/Users/username/Library/R/arm64/4.2/library/terra’
Warning in install.packages :
installation of package ‘terra’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/zp/vysqcnr95g5d08jhlmzrvj9m0000gn/T/RtmpfniygU/downloaded_packages’
我真的需要光栅 package。请帮忙。
确保您的系统上安装了Rtools (单击此处)。 然后尝试以下步骤:
1- 当您打开 RStudio 时,右键单击该图标并选择“以管理员身份运行”。
2- 暂时停用您的防火墙或防病毒软件。
3- 使用以下命令:
install.packages('raster', dependencies=TRUE, repos='https://CRAN.R-project.org/')
library(raster)
看看问题是否解决。
你能编辑你的问题并展示你跑步时会发生什么吗
install.packages('terra')
install.packages('raster')
如果不需要,我不会从源代码安装。 但如果必须,请先安装“terra”。 有关从源代码安装的说明,请参阅https://github.com/rspatial/terra 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.