Installation Issue - no valid installation of tensorflow

Open
#622 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
r, tensorflow

Research direction

Start by reviewing the install_tensorflow(), tf_config(), and reticulate Python-initialization paths, using the reported Windows, Python 3.11, TensorFlow 2.18 setup to reproduce the failure. Compare the environment selected by py_config() with the environment created by installation; done means tensorflow::tf_config() and reticulate::import("tensorflow") both succeed.

Written by the indexing model from the issue text.

Description

Hi,

I'm having problems installing tensorflow.

I can add the following code:

install_tensorflow(envname = "C:\Users\LynseyMcColl\AppData\Local\r-tensorflow", method = "conda", python_version = "3.11", version = "2.18")

Which says the installation is successful but when I then try it out I get the following error message:
Error: Valid installation of TensorFlow not found.

I have set an envname above as I am working on one drive and so have pointed it to the desktop rather than an online environment which I've read can cause problems.

I've put the messages I get to the commands requested below.

Many thanks,

Lynsey

reticulate::py_config()

libpython:      C:/Users/LynseyMcColl/AppData/Local/Programs/Python/Python311/python311.dll
pythonhome:     C:/Users/LynseyMcColl/AppData/Local/Programs/Python/Python311
version:        3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
Architecture:   64bit
numpy:           [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\LynseyMcColl\AppData\Local\Programs\Python\Python311\python.exe

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


You can install TensorFlow using the install_tensorflow() function.
 
Warning message:
ModuleNotFoundError: No module named 'tensorflow'
Run `reticulate::py_last_error()` for details.
Restart the R session and load the tensorflow R package before reticulate has initialized Python, or ensure reticulate initialized a Python installation where the tensorflow module is installed.

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\LynseyMcColl\AppData\Local\R\win-library\4.4\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\LynseyMcColl\AppData\Local\R\win-library\4.4\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
             ^^^^^^
  File "C:\Users\LynseyMcColl\AppData\Local\R\win-library\4.4\reticulate\python\rpytools\loader.py", line 120, 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)
See `reticulate::py_last_error()$r_trace$full_call` for more details.

sessionInfo()

R version 4.4.3 (2025-02-28 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8   
[3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    

time zone: Europe/London
tzcode source: internal

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

loaded via a namespace (and not attached):
 [1] base64enc_0.1-3        Matrix_1.7-2           lattice_0.22-6         reticulate_1.42.0     
 [5] magrittr_2.0.3         glue_1.8.0             png_0.1-8              lifecycle_1.0.4       
 [9] cli_3.6.4              tensorflow_2.16.0.9000 vctrs_0.6.5            grid_4.4.3            
[13] tfruns_1.5.3           compiler_4.4.3         rstudioapi_0.17.1      tools_4.4.3           
[17] whisker_0.4.1          pillar_1.10.1          Rcpp_1.0.14            rlang_1.1.5           
[21] jsonlite_2.0.0   

Dominant language
R
Stars
1.3k
Forks
316
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rstudio/tensorflow

All issues in rstudio/tensorflow

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.