软件包“ keras”已成功安装,但无法加载?

时间:2019-05-19 07:11:55

标签: r keras

我试图在Win10 + Rstudio 1.2上安装keras,已成功安装,但无法加载。 尝试解除安装并重新安装,但错误仍然存​​在。

请告知。

> install.packages("keras")
Installing package into ‘C:/Users/eric1/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.5:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.5/PACKAGES'
trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/bin/windows/contrib/3.5/keras_2.1.6.zip'
Content type 'application/zip' length 2340096 bytes (2.2 MB)
downloaded 2.2 MB

package ‘keras’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\eric1\AppData\Local\Temp\RtmpaynDb0\downloaded_packages


> library(keras)
Error: package or namespace load failed for ‘keras’ in rbind(info, getNamespaceInfo(env, "S3methods")):
 number of columns of matrices must match (see arg 2)

而回溯是

> traceback()
6: stop(msg, call. = FALSE, domain = NA)
5: value[[3L]](cond)
4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
3: tryCatchList(expr, classes, parentenv, handlers)
2: tryCatch({
       attr(package, "LibPath") <- which.lib.loc
       ns <- loadNamespace(package, lib.loc)
       env <- attachNamespace(ns, pos = pos, deps)
   }, error = function(e) {
       P <- if (!is.null(cc <- conditionCall(e))) 
           paste(" in", deparse(cc)[1L])
       else ""
       msg <- gettextf("package or namespace load failed for %s%s:\n %s", 
           sQuote(package), P, conditionMessage(e))
       if (logical.return) 
           message(paste("Error:", msg), domain = NA)
       else stop(msg, call. = FALSE, domain = NA)
   })
1: library(keras)

1 个答案:

答案 0 :(得分:0)

有了这篇文章的提示,我检查了reticulate,并得到了相同的错误消息,我确信它是很好的。因此,我确定根源是Python和Anaconda。 我重新安装了python和anaconda,并解决了该问题。

只做一个笔记,希望它可以帮助那些像我一样愚蠢的人。

package or namespace load failed for ‘keras’ #268