首页 > 解决方案 > devtools::check() - 没有名为“Matrix”的包

问题描述

我想为 CRAN 准备我的第一个包,并不断面临这个错误

在 Rstudio 时:


> devtools::check(args = c('--as-cran'))

错误是:


** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called ‘Matrix’
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
ERROR: lazy loading failed for package 
1 error x | 0 warnings ✓ | 0 notes ✓
Error: R CMD check found ERRORs
Execution halted

什么时候:

$ R CMD check pkgname*.tar.gz

一切都很好,并且通过了检查。

对于错误,我几乎尝试了网络上所有可能的解决方案,例如123456等等,但没有成功。

sessionInfo()

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /opt/microsoft/ropen/4.0.2/lib64/R/lib/libRblas.so
LAPACK: /opt/microsoft/ropen/4.0.2/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] eumap_0.0.4          RevoUtils_11.0.2     RevoUtilsMath_11.0.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5             paradox_0.7.0          lattice_0.20-41       
 [4] listenv_0.8.0          prettyunits_1.1.1      ps_1.5.0              
 [7] assertthat_0.2.1       rprojroot_1.3-2        digest_0.6.25         
[10] R6_2.4.1               ranger_0.12.1          backports_1.1.8       
[13] ggplot2_3.3.2          pillar_1.4.6           rlang_0.4.10.9000     
[16] uuid_0.1-4             rstudioapi_0.11        data.table_1.12.8     
[19] whisker_0.4            callr_3.5.1            raster_3.3-7          
[22] Matrix_1.2-18          checkmate_2.0.0        mlr3spatiotempcv_0.1.1
[25] devtools_2.3.0         desc_1.2.0             stringr_1.4.0         
[28] munsell_0.5.0          compiler_4.0.2         xfun_0.15             
[31] pkgconfig_2.0.3        pkgbuild_1.1.0         globals_0.12.5        
[34] tidyselect_1.1.0       tibble_3.0.3           lgr_0.3.4             
[37] roxygen2_7.1.1         mlr3misc_0.7.0         codetools_0.2-16      
[40] fansi_0.4.1            future_1.18.0          crayon_1.3.4          
[43] dplyr_1.0.0            withr_2.4.0            commonmark_1.7        
[46] grid_4.0.2             gtable_0.3.0           lifecycle_0.2.0       
[49] git2r_0.27.1           magrittr_2.0.1         scales_1.1.1          
[52] cli_2.2.0              stringi_1.4.6          remotes_2.2.0         
[55] fs_1.5.0               sp_1.4-5               testthat_3.0.1        
[58] xml2_1.3.2             ellipsis_0.3.1         vctrs_0.3.2           
[61] generics_0.0.2         rcmdcheck_1.3.3        tools_4.0.2           
[64] mlr3_0.10.0            glue_1.4.1             purrr_0.3.4           
[67] processx_3.4.5         pkgload_1.1.0          parallel_4.0.2        
[70] colorspace_1.4-1       terra_0.7-11           xopen_1.0.0           
[73] sessioninfo_1.1.1      memoise_1.1.0          knitr_1.29            
[76] usethis_1.6.1  

我在 Ubuntu 20.4 上运行。

在这里帮助我。

标签: rubuntumatrixpackage

解决方案


问题终于解决了。我的步骤的工作流程如下:

1-我尝试了@r2evans的第一种方法,但没有奏效,

2- 根据@r2evans、@user2554330 和@pat-s 的解决方案,我删除了 Microsoft-R

3-我安装了 R-CRAN_4.3,R 在这个阶段工作在默认的BLASLAPACK上。这是在 linux 上使用默认 BLAS/LAPACK 库时的输出:

## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

但是,要利用硬件并进行必须更改的多线程处理。有几个高度优化的库可以用来代替默认的基础库。我主要使用Dirk Eddelbuettel的这个非常有趣且易于理解/实现的方法。因此,我将第 4 步执行为:

4-为基于 .deb 的系统和集成的 MKL安装MKL ,

5-删除所有以前安装的软件包,

6-重新安装中提到的所有依赖项和建议的库R-package/Description

7-运行R CMD CHECK --as-CRAN最后完成!.

注意:如果你(像我一样)不知道 BLAS 是什么,这里有一篇非常酷的帖子。我使用的其他来源是:1、23

并感谢大家的意见和建议。@r2evans,@user2554330,@pat-s


推荐阅读