Installing and running Tensorflow in R Studio

Please, I have been having trouble for weeks now trying to install and run tensorflow and keras in R Studio. I have tried everything I can find online to no avail. I have anaconda installed on my system, do I need to uninstall it? After running this line of code:


install_tensorflow(method = "conda",version = "default", envname = "py3.6",
                   conda_python_version = "3.6",
                   extra_packages = c("matplotlib","numpy","pandas","scikit-learn"))
install_keras(method = "conda")

It says installation successful, but when I now run tf$constant("Hellow Tensorflow") I get the following error message:

Error: Installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 C:\Users\IFEANYI\AppData\Local\r-miniconda\envs\r-reticulate\python.exe

You can install TensorFlow using the install_tensorflow() function.

I also try to install keras using:


install_keras(method = "conda")
install_keras(tensorflow = "default")

But I also get an error message:

Error in install_keras(method = "conda") : 
  You should call install_keras() only in a fresh R session that has not yet initialized Keras and TensorFlow (this is to avoid DLL in use errors during installation)

I also have reticulate installed in R Studio. I honestly do not know why it is such a task to install and run tensorflow in R. I have been on it for weeks without any tangible headway. Please, as always I will be extremely grateful if someone can help me resolve this nagging issue

Please, can someone be so kind as to give my issue a looking? Thanks

Do you have multiple versions of python installed? I wonder if there could be a version confusion, and R is trying to find tensorflow in the wrong python version.

It looks like R is looking for tensorflow here:

 C:\Users\IFEANYI\AppData\Local\r-miniconda\envs\r-reticulate\python.exe

I wonder if your install statement installed it somewhere else.

If you don't get a good answer from anyone on this forum, you might try to uninstall all python on your machine. Then install one version fresh and install tensorflow yourself.

Thanks. I have actually uninstalled all python except Anaconda. Do I go on to uninstall that as well, and then reinstall it?

You can try to keep it. Make sure that python from the command line is linked to that install, and RStudio is liked to it as well through the options.

Okay, I will try that. Thanks

This topic was automatically closed 21 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.