rstudio / tensorflow

TensorFlow for R
https://tensorflow.rstudio.com
Apache License 2.0
1.32k stars 317 forks source link

Installation Issue #556

Closed JamesHall3525 closed 1 year ago

JamesHall3525 commented 1 year ago

Team,

I am following this how to guide and running into an error.

Installation Guide: https://tensorflow.rstudio.com/install/

Code

This is how I installed

install.packages("tensorflow") library(reticulate) path_to_python <- install_python() virtualenv_create("r-reticulate", python = path_to_python) library(tensorflow) install_tensorflow(envname = "r-reticulate") install.packages("keras") library(keras) install_keras(envname = "r-reticulate")

Final Lines that causes the error

library(tensorflow) library(keras) c(c(x_train, y_train), c(x_test, y_test)) %<-% keras::dataset_mnist()

RESULT:

Error: Valid installation of TensorFlow not found. Python environments searched for 'tensorflow' package: C:\Users\jhall\AppData\Local\r-miniconda\envs\r-reticulate\python.exe Python exception encountered: Traceback (most recent call last): File "C:\Users\jhall\AppData\Local\R\win-library\4.2\reticulate\python\rpytools\loader.py", line 119, in _find_and_load_hook return _run_hook(name, _hook) File "C:\Users\jhall\AppData\Local\R\win-library\4.2\reticulate\python\rpytools\loader.py", line 93, in _run_hook module = hook() File "C:\Users\jhall\AppData\Local\R\win-library\4.2\reticulate\python\rpytools\loader.py", line 117, in _hook return _find_andload(name, import) ModuleNotFoundError: No module named 'tensorflow' You can install TensorFlow using the install_tensorflow() function.

JamesHall3525 commented 1 year ago

UPDATE Screenshots Attached After running recommended code:

screenshot.pptx

t-kalinowski commented 1 year ago

It looks like you have two environments named "r-reticulate", one a conda environment, the other a virtual environment. When you call install_tensorflow(), tensorflow (the python package) is installed into the virtual environment, but then reticulate is binding to the condaenv instead of the virtualenv.

You can uninstall the miniconda env like this:

reticulate::miniconda_uninstall()

After this, reticulate should default to the virtual env where tensorflow is already installed.

github-actions[bot] commented 1 year ago

Automatically closed because there has not been a response for 30 days. When you're ready to work on this further, please comment here and the issue will automatically reopen.