簡體   English   中英

無法在 R 中安裝“光柵”package

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM