Error: package or namespace load failed for 'keras'

Hi, I am new to R studio and I tried to install keras as following:

if("keras" %in% rownames(installed.packages()) == FALSE) {

but the process of command line tools was terminated and it results in below error:

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

and when i tried to run the original code again, it doesn't work anymore.

Can anyone advise how to solve it? Thanks a lot!

You are missing the Rcpp package, try installing it first, do you get any error message while doing so?


Thanks for your advice. I tried the code and have below result:

> install.packages("Rcpp")
trying URL ''
Content type 'application/x-gzip' length 3320151 bytes (3.2 MB)
downloaded 3.2 MB

The downloaded binary packages are in

and run the below code again:

> if("keras" %in% rownames(installed.packages()) == TRUE) {
+     install.packages('keras')
+     library(keras)
+     install_keras()
+ }

After a moment, it results in:

Installation complete.
Restarting R session...

Is that mean I have successfully installed it? Because this time it does not request me to run the command line tools, but it did request me for the last time.


Yes, if you do not get any error message then you have installed it successfully

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.