尝试安装插入包时loadNameSpaces出错

时间:2017-03-09 21:51:04

标签: r package

enter image description here

library(caret)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
there is no package called ‘SparseM’
Error: package or namespace load failed for ‘caret’

我已经尝试了

install.packages("SparseM", dependencies = TRUE)
install.packages("caret", dependencies = TRUE)

但仍然有同样的错误。

使用以下输出安装了这两个软件包时没有错误。

> install.packages("SparseM", dependencies = TRUE)

  There is a binary version available but the source version
  is later:
        binary source needs_compilation
SparseM   1.74   1.76              TRUE

Do you want to install from sources the package which needs compilation?
y/n: y
installing the source package ‘SparseM’

trying URL 'https://cran.rstudio.com/src/contrib/SparseM_1.76.tar.gz'
Content type 'application/x-gzip' length 737953 bytes (720 KB)
==================================================
downloaded 720 KB

* installing *source* package ‘SparseM’ ...
** package ‘SparseM’ successfully unpacked and MD5 sums checked
** libs
gfortran-4.8   -fPIC  -g -O2  -c bckslv.f -o bckslv.o
make: gfortran-4.8: No such file or directory
make: *** [bckslv.o] Error 1
ERROR: compilation failed for package ‘SparseM’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/SparseM’
Warning in install.packages :
  installation of package ‘SparseM’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/jm/6j0dddmn16nfvy5jq81dhcl00000gn/T/Rtmpur0I1l/downloaded_packages’

也安装了Caret包,没有错误。

> install.packages("caret", dependencies = TRUE)
trying URL 'https://cran.rstudio.com/bin/macosx/mavericks/contrib/3.3/caret_6.0-73.tgz'
Content type 'application/x-gzip' length 4885901 bytes (4.7 MB)
==================================================
downloaded 4.7 MB


The downloaded binary packages are in
    /var/folders/jm/6j0dddmn16nfvy5jq81dhcl00000gn/T//Rtmpur0I1l/downloaded_packages

1 个答案:

答案 0 :(得分:1)

这里的问题是没有安装SparseM,因为由于缺少gfortran而导致源代码编译失败。一种解决方案:在提示时不要从源安装。