Error Installing TensorFlow for R

Months ago, I was able to install TensorFlow and utilize it with the keras package to build my own models. It worked perfectly then, but in revisiting it today, I found the same code no longer works. In trying to do anything with the package, I'd receive the following error.

> tf$constant("")
List of 20
 $ python              : chr "C:/Users/brend/AppData/Local/Programs/Python/Python311/python.exe"
 $ libpython           : chr "C:/Users/brend/AppData/Local/Programs/Python/Python311/python311.dll"
 $ pythonhome          : chr "C:/Users/brend/AppData/Local/Programs/Python/Python311"
 $ pythonpath          : chr "C:\\Users\\brend\\AppData\\Local\\R\\win-library\\4.2\\reticulate\\config;C:\\Users\\brend\\AppData\\Local\\Pro"| __truncated__
 $ prefix              : chr "C:\\Users\\brend\\AppData\\Local\\Programs\\Python\\PYTHON~2"
 $ exec_prefix         : chr "C:\\Users\\brend\\AppData\\Local\\Programs\\Python\\PYTHON~2"
 $ base_exec_prefix    : chr "C:\\Users\\brend\\AppData\\Local\\Programs\\Python\\PYTHON~2"
 $ virtualenv          : chr ""
 $ virtualenv_activate : chr ""
 $ version_string      : chr "3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]"
 $ version             : chr "3.11"
 $ architecture        : chr "64bit"
 $ anaconda            : logi FALSE
 $ conda               : logi FALSE
 $ numpy               : NULL
 $ required_module     : chr "tensorflow"
 $ required_module_path: NULL
 $ available           : logi TRUE
 $ python_versions     : chr "C:/Users/brend/AppData/Local/Programs/Python/Python311/python.exe"
 $ forced              : chr "RETICULATE_PYTHON_FALLBACK"
 - attr(*, "class")= chr "py_config"
Error: Python module tensorflow was not found.

Detected Python configuration:

I found I couldn't download the keras library either due to the same error.

> library(keras)
Error: package or namespace load failed for ‘keras’:
 .onLoad failed in loadNamespace() for 'keras', details:
  call: py_module_import(module, convert = convert)
  error: ModuleNotFoundError: No module named 'tensorflow'
In addition: Warning message:
package ‘keras’ was built under R version 4.2.2 

In trying to resolve this error, I reinstalled TensorFlow by following the instructions given in this link (TensorFlow for R - Quick start). However, when I reached the point to define a constant in TensorFlow again, I received the same error.

Does anyone have any idea what could be happening here? Any help would be appreciated.

Is this in RStudio in a terminal app or both?

Just RStudio. I haven't tried it in the terminal

This might help.

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.