Tensorflow works in R command line but not Rstudio

Viewed 171

I have installed the tensorflow package.

The following commands work fine in R command line

library(tensorflow)
sess = tf$Session

However when I run the same 2 linesin Rstudio I get the following error

Error: Python module tensorflow was not found
Detected Python configuration:

...
numpy:           [NOT FOUND]

I suspect its numpy related but I have no idea.

This is my Rstudio information

rstudio::versionInfo()
$version
[1] ‘0.98.1103’
$mode
[1] "desktop"

Do I need to use a different version of Rstudio or is there more setup required to get tensorflow to work?

A bit more details after reading https://github.com/rstudio/tensorflow/issues/87

import('numpy')

Error in py_module_import(module, convert = convert) : ImportError: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: DLL load failed: The specified path is invalid.

**************** FINAL EDIT *********************

I got this to work. But I have no idea why or how. During install_tensorflow() in Rstudio, you are prompted to add the following to your PATH so I did

usr\appdata\local\programs\python\python36\Scripts

I removed it from my PATH and successfully ran tensorflow in Rstudio.

However, I added it back subsequently and could not replicate the error. In the end I still don't know what is broken in Rstudio or what fixed it

1 Answers

Please use the following command to reload dynamic library paths

sudo ldconfig
Related