Skip to content

Installation Issue #593

@rbenel

Description

@rbenel

Hi,

I am able to successfully install keras and tensorflow using the following lines

#desginate local path to python 
path_to_python <- "C:/Users/Hadarma/AppData/Local/Programs/Python/Python310"
#then create v_env within this version of python 
virtualenv_create("r-reticulate", python = path_to_python)
#install tensroflow and keras in v_env
install_tensorflow(envname = "r-reticulate")
install_keras(envname = "r-reticulate")
#use this v_env
use_virtualenv("r-reticulate")

However as soon as I close the .Rproject I am unable to successfully use the packages. For example if I run this line

model <- keras::keras_model_sequential()

this is the output I will receive.

Error: Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 C:\Users\Hadarma\AppData\Local\Programs\Python\Python310\python.exe

Python exception encountered:
 Traceback (most recent call last):
  File "C:\Users\Hadarma\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 119, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\Hadarma\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 93, in _run_hook
    module = hook()
  File "C:\Users\Hadarma\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 117, in _hook
    return _find_and_load(name, import_)
ModuleNotFoundError: No module named 'tensorflow'


You can install TensorFlow using the install_tensorflow() function.

Since the above installation clearly fails, here is the info requested :)

reticulate::py_config()
python:         C:/Users/Hadarma/AppData/Local/Programs/Python/Python310/python.exe
libpython:      C:/Users/Hadarma/AppData/Local/Programs/Python/Python310/python310.dll
pythonhome:     C:/Users/Hadarma/AppData/Local/Programs/Python/Python310
version:        3.10.9 (tags/v3.10.9:1dd9be6, Dec  6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]
Architecture:   64bit
numpy:           [NOT FOUND]
tensorflow:     [NOT FOUND]

NOTE: Python version was forced by use_python() function
tensorflow::tf_config()

Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 C:\Users\Hadarma\AppData\Local\Programs\Python\Python310\python.exe

Python exception encountered:
 Traceback (most recent call last):
  File "C:\Users\Hadarma\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 119, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\Hadarma\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 93, in _run_hook
    module = hook()
  File "C:\Users\Hadarma\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 117, in _hook
    return _find_and_load(name, import_)
ModuleNotFoundError: No module named 'tensorflow'


You can install TensorFlow using the install_tensorflow() function.
reticulate::import("tensorflow")

Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'tensorflow'
Run `reticulate::py_last_error()` for details.
reticulate::py_last_error()
── Python Exception Message ──────────────────────────────────────────────────────────────────────────────────────
Traceback (most recent call last):
  File "C:\Users\Hadarma\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 119, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\Hadarma\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 93, in _run_hook
    module = hook()
  File "C:\Users\Hadarma\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 117, in _hook
    return _find_and_load(name, import_)
ModuleNotFoundError: No module named 'tensorflow'

── R Traceback ───────────────────────────────────────────────────────────────────────────────────────────────────
    ▆
 1. └─reticulate::import("tensorflow")
 2.   └─reticulate:::py_module_import(module, convert = convert)
sessionInfo()

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_Israel.utf8  LC_CTYPE=English_Israel.utf8    LC_MONETARY=English_Israel.utf8
[4] LC_NUMERIC=C                    LC_TIME=English_Israel.utf8    

time zone: Asia/Jerusalem
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tensorflow_2.15.0.9000

loaded via a namespace (and not attached):
 [1] R6_2.5.1               base64enc_0.1-3        Matrix_1.6-1           lattice_0.21-8        
 [5] reticulate_1.35.0.9000 magrittr_2.0.3         rappdirs_0.3.3         generics_0.1.3        
 [9] png_0.1-8              lifecycle_1.0.4        cli_3.6.1              pak_0.7.1             
[13] grid_4.3.1             zeallot_0.1.0          tfruns_1.5.2           compiler_4.3.1        
[17] rstudioapi_0.15.0      tools_4.3.1            whisker_0.4.1          Rcpp_1.0.11           
[21] rlang_1.1.1            jsonlite_1.8.7 

Thanks for all the help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions