简体   繁体   中英

Error in loadNameSpaces when trying to install caret packages

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’

I've tried

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

but still got the same error.

Both packages were installed without error with the following output.

> 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 package were also installed without error.

> 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

The issue here was that SparseM was not installed, as compilation from source failed due to missing gfortran. One solution: don't install from source when prompted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM