rstudio / tensorflow

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

Installation Issue #593

Open rbenel opened 3 months ago

rbenel commented 3 months ago

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!

t-kalinowski commented 3 months ago

The error messages indicate that reticulate is not binding to the virtual env "r-reticulate", but rather, to the venv starter used, ~/../AppData/Local/Programs/Python/Python310. We'll have to figure out why.

In a fresh R session, what is the output from running:

library(reticulate)
use_virtualenv("r-reticulate")
py_config()

If that succeeds, then likely the RStudio IDE is redirecting reticulate to select the "wrong" python installation. You can modify or disable this IDE feature under "Tools > Global Options > Python". My recommendation is to disable the IDE feature (uncheck the box, leave the text field empty"), and to do all reticulate/python managment from either a project local .Rprofile or .Renviron, or at the start of your project R scripts.

If that fails, then please post the full output from running these commands that venv from scratch, and we'll try to figure out the cause:

# restart R session, Ctrl+Shift+F10 
tensorflow::install_tensorflow(envname = "r-reticulate", version = "release", new_env = TRUE)
use_virtualenv("r-reticulate")
py_config()
rbenel commented 3 months ago

Hi Tomasz,

I sort of figured out that the issue had to do to with the interpreter and I also discovered the "Tools > Global Options > Python" settings. What I found worked on that specific computer was to allow the Python Interpreter to access virtual environments and I used this bit of code.

#make sure in global options the virtual environment is selected as a python interpreter
#also make sure using a fresh R session 

#load libraries 
install.packages("tensorflow")
install.packages("keras")
library(reticulate)
library(keras)
library(tensorflow)

#create virtual environment 
virtualenv_create("myenv")
#use the virtual environment we names "myenv"
use_virtualenv("myenv")
#finally install the package in the same place 
install_keras(method="virtualenv", envname="myenv")
#to the same for tensorflow
use_virtualenv("myenv")
install_tensorflow(method="virtualenv", envname="myenv")

#test to see if actually works 
tensorflow::as_tensor("Hello World")

After doing this and checking the "Global Options" I was able to start a new R session and the installation remained. However, I would like to solve it the proper way, because as soon as I tried on a colleagues computer I ran into other issues which may be due to an outdated version of Python i.e. 3.9 v. on my computer 3.10? (see below at the end of the thread)

So in a fresh R session I ran

library(reticulate) 
use_virtualenv("r-reticulate") 

Warning message:
Previous request to `use_python("C:/Users/Hadarma/Documents/.virtualenvs/myenv/Scripts/python.exe", required = TRUE)` will be ignored. It is superseded by request to `use_python("C:/Users/Hadarma/Documents/.virtualenvs/r-reticulate/Scripts/python.exe") 
py_config()
python:         C:/Users/Hadarma/Documents/.virtualenvs/r-reticulate/Scripts/python.exe
libpython:      C:/Users/Hadarma/AppData/Local/Programs/Python/Python310/python310.dll
pythonhome:     C:/Users/Hadarma/Documents/.virtualenvs/r-reticulate
version:        3.10.9 (tags/v3.10.9:1dd9be6, Dec  6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:/Users/Hadarma/Documents/.virtualenvs/r-reticulate/Lib/site-packages/numpy
numpy_version:  1.24.3
tensorflow:     C:\Users\Hadarma\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\__init__.p

NOTE: Python version was forced by use_python() function

Is this the output expected?

When you say uncheck the box in "Tools > Global Options > Python" you mean uncheck "Automatically activate project-local Python environments" and not to select any Python Interpreter (see picture)

image

This is from my colleagues computer when running the same lines you requested: image

Thanks so much!

t-kalinowski commented 3 months ago

Progress! It looks like you have things in a working state now. We should still aim to get rid of the warning.

Two notes:

Note that in many situations, there is no need to point reticulate at a python, at all. If you call install_keras(), it will create a venv that will automatically be discovered by reticulate. Similarly, if you want to make a project specific venv, you can do install_keras(envname = "./venv") and reticulate will automatically discover that also.

This might be helpful: https://rstudio.github.io/reticulate/articles/versions.html#order-of-discovery

rbenel commented 3 months ago

Hi Tomasz, Thanks for the detailed response and tips!

In the first attempt at installation I tried to point r-reticulate to the local Python version installed here "C:/Users/Hadarma/AppData/Local/Programs/Python/Python310" and then created a venv is this the preferred method?

From what I am seeing based on your comments you should be able to use keras and or tensorflow just with a venv which r-reticulate can create if it's not already created.

Is this correct? Thanks!

rbenel commented 2 months ago

Hi @t-kalinowski,

Me again. I am still trying to install tensorflow on various computers for my team and I am not always successful.

Today just to see if my venv was working properly I downloaded version 3.8 Python and saved that path of the executable to feed into `reticulate::virtualenv_create("r-reticulate", python = path_to_python).

This line install_tensorflow(envname="r-reticulate"), doesn't give me an error but when I try to check the installation I receive a python error that the module isn't found so I tried some simpler packages like thispy_install("pandas")and thenpandas <- import("pandas") which works perfectly.

I am thinking maybe this has to do with the tensorflow installation from github? remotes::install_github("rstudio/tensorflow") is this possible?

See terrible picture of screen, the error is basically "unhashable type list". I have been working on these installations for weeks and on 2 computers it works fine and all of the rest is doesn't. Right now I am using a formatted computer and started completely fresh.

Thanks!

WhatsApp Image 2024-04-16 at 20 30 52

t-kalinowski commented 2 months ago

Hi @rbenel, I'm happy to help, but I need more info to properly diagnose what's going wrong. Can you please fill out the "installation issue" template: https://github.com/rstudio/tensorflow/blob/main/.github/ISSUE_TEMPLATE/installation-issue.md

rbenel commented 2 months ago
reticulate::py_config()
python:         C:/Users/moshek/Documents/.virtualenvs/r-reticulate/Scripts/python.exe
libpython:      C:/Users/moshek/AppData/Local/Programs/Python/Python39/python39.dll
pythonhome:     C:/Users/moshek/Documents/.virtualenvs/r-reticulate
version:        3.9.1rc1 (tags/v3.9.1rc1:88db374, Nov 24 2020, 19:40:11) [MSC v.1927 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:/Users/moshek/Documents/.virtualenvs/r-reticulate/Lib/site-packages/numpy
numpy_version:  1.26.4
tensorflow:     C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\__init__.p
tensorflow::tf_config()
2024-04-17 09:27:42.757578: W external/local_tsl/tsl/lib/monitoring/collection_registry.cc:81] Trying to register 2 metrics with the same name: /tensorflow/api/ops_eager_execution. The old value will be erased in order to register a new one. Please check if you link the metric more than once, or if the name is already used by other metrics.
2024-04-17 09:27:42.758862: W external/local_tsl/tsl/lib/monitoring/collection_registry.cc:81] Trying to register 2 metrics with the same name: /tensorflow/api/enable_control_flow_v2. The old value will be erased in order to register a new one. Please check if you link the metric more than once, or if the name is already used by other metrics.
2024-04-17 09:27:42.759641: W external/local_tsl/tsl/lib/monitoring/collection_registry.cc:81] Trying to register 2 metrics with the same name: /tensorflow/api/tf_function. The old value will be erased in order to register a new one. Please check if you link the metric more than once, or if the name is already used by other metrics.
2024-04-17 09:27:42.980938: W external/local_tsl/tsl/lib/monitoring/collection_registry.cc:81] Trying to register 2 metrics with the same name: /tensorflow/api/ops_eager_execution. The old value will be erased in order to register a new one. Please check if you link the metric more than once, or if the name is already used by other metrics.
2024-04-17 09:27:42.981573: W external/local_tsl/tsl/lib/monitoring/collection_registry.cc:81] Trying to register 2 metrics with the same name: /tensorflow/api/enable_control_flow_v2. The old value will be erased in order to register a new one. Please check if you link the metric more than once, or if the name is already used by other metrics.
2024-04-17 09:27:42.982242: W external/local_tsl/tsl/lib/monitoring/collection_registry.cc:81] Trying to register 2 metrics with the same name: /tensorflow/api/tf_function. The old value will be erased in order to register a new one. Please check if you link the metric more than once, or if the name is already used by other metrics.
Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 C:\Users\moshek\Documents\.virtualenvs\r-reticulate\Scripts\python.exe

Python exception encountered:
 Traceback (most recent call last):
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\__init__.py", line 49, in <module>
    from ._api.v2 import __internal__
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\_api\v2\__internal__\__init__.py", line 10, in <module>
    from . import autograph
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\_api\v2\__internal__\autograph\__init__.py", line 10, in <module>
    from tensorflow.python.autograph.core.ag_ctx import control_status_ctx
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\python\autograph\core\ag_ctx.py", line 21, in <module>
    from tensorflow.python.autograph.utils import ag_logging
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\python\autograph\utils\__init__.py", line 17, in <module>
    from tensorflow.python.autograph.utils.context_managers import control_dependency_on_returns
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\python\autograph\utils\context_managers.py", line 19, in <module>
    from tensorflow.python.framework import ops
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\python\framework\ops.py", line 5906, in <module>
    ) -> Optional[Callable[[Any], message.Message]]:
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 262, in inner
    return func(*args, **kwds)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 339, in __getitem__
    return self._getitem(self, parameters)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 463, in Optional
    return Union[arg, type(None)]
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 262, in inner
    return func(*args, **kwds)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 339, in __getitem__
    return self._getitem(self, parameters)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 451, in Union
    parameters = _remove_dups_flatten(parameters)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 231, in _remove_dups_flatten
    return tuple(_deduplicate(params))
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 205, in _deduplicate
    all_params = set(params)
TypeError: unhashable type: 'list'

You can install TensorFlow using the install_tensorflow() function.
reticulate::import("tensorflow")
2024-04-17 09:27:44.503140: W external/local_tsl/tsl/lib/monitoring/collection_registry.cc:81] Trying to register 2 metrics with the same name: /tensorflow/api/ops_eager_execution. The old value will be erased in order to register a new one. Please check if you link the metric more than once, or if the name is already used by other metrics.
2024-04-17 09:27:44.504118: W external/local_tsl/tsl/lib/monitoring/collection_registry.cc:81] Trying to register 2 metrics with the same name: /tensorflow/api/enable_control_flow_v2. The old value will be erased in order to register a new one. Please check if you link the metric more than once, or if the name is already used by other metrics.
2024-04-17 09:27:44.505163: W external/local_tsl/tsl/lib/monitoring/collection_registry.cc:81] Trying to register 2 metrics with the same name: /tensorflow/api/tf_function. The old value will be erased in order to register a new one. Please check if you link the metric more than once, or if the name is already used by other metrics.
Error in py_module_import(module, convert = convert) : 
  TypeError: unhashable type: 'list'
Run `reticulate::py_last_error()` for details.
reticulate::py_last_error()

── Python Exception Message ───────────────────────────────────────────────────────
Traceback (most recent call last):
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\__init__.py", line 49, in <module>
    from ._api.v2 import __internal__
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\_api\v2\__internal__\__init__.py", line 10, in <module>
    from . import autograph
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\_api\v2\__internal__\autograph\__init__.py", line 10, in <module>
    from tensorflow.python.autograph.core.ag_ctx import control_status_ctx
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\python\autograph\core\ag_ctx.py", line 21, in <module>
    from tensorflow.python.autograph.utils import ag_logging
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\python\autograph\utils\__init__.py", line 17, in <module>
    from tensorflow.python.autograph.utils.context_managers import control_dependency_on_returns
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\python\autograph\utils\context_managers.py", line 19, in <module>
    from tensorflow.python.framework import ops
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)
  File "C:\Users\moshek\DOCUME~1\VIRTUA~1\R-RETI~1\lib\site-packages\tensorflow\python\framework\ops.py", line 5906, in <module>
    ) -> Optional[Callable[[Any], message.Message]]:
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 262, in inner
    return func(*args, **kwds)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 339, in __getitem__
    return self._getitem(self, parameters)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 463, in Optional
    return Union[arg, type(None)]
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 262, in inner
    return func(*args, **kwds)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 339, in __getitem__
    return self._getitem(self, parameters)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 451, in Union
    parameters = _remove_dups_flatten(parameters)
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 231, in _remove_dups_flatten
    return tuple(_deduplicate(params))
  File "C:\Users\moshek\AppData\Local\Programs\Python\Python39\lib\typing.py", line 205, in _deduplicate
    all_params = set(params)
TypeError: unhashable type: 'list'

── 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.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

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

time zone: Asia/Jerusalem
tzcode source: internal

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

other attached packages:
[1] reticulate_1.36.0      tensorflow_2.16.0.9000

loaded via a namespace (and not attached):
 [1] base64enc_0.1-3   Matrix_1.6-5      lattice_0.22-5    magrittr_2.0.3   
 [5] rappdirs_0.3.3    png_0.1-8         lifecycle_1.0.4   cli_3.6.2        
 [9] grid_4.3.3        tfruns_1.5.2      compiler_4.3.3    rprojroot_2.0.4  
[13] here_1.0.1        rstudioapi_0.16.0 tools_4.3.3       whisker_0.4.1    
[17] Rcpp_1.0.12       rlang_1.1.3       jsonlite_1.8.8
t-kalinowski commented 2 months ago

What is the output if you run:

# install the latest CRAN releases
install.packages(c("tensorflow", "reticulate", "keras3"))
# restart the R session
.rs.restartR()

reticulate::install_python()

tensorflow::install_tensorflow()
rbenel commented 2 months ago
install.packages(c("tensorflow", "reticulate", "keras3"))
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing packages into ‘C:/Users/Tapat1/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
also installing the dependency ‘zeallot’

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/zeallot_0.1.0.zip'
Content type 'application/zip' length 62117 bytes (60 KB)
downloaded 60 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/tensorflow_2.16.0.zip'
Content type 'application/zip' length 213856 bytes (208 KB)
downloaded 208 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/reticulate_1.36.1.zip'
Content type 'application/zip' length 2183538 bytes (2.1 MB)
downloaded 2.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/keras3_0.2.0.zip'
Content type 'application/zip' length 8682075 bytes (8.3 MB)
downloaded 8.3 MB

package ‘zeallot’ successfully unpacked and MD5 sums checked
package ‘tensorflow’ successfully unpacked and MD5 sums checked
package ‘reticulate’ successfully unpacked and MD5 sums checked
package ‘keras3’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\Tapat1\AppData\Local\Temp\RtmpWYj7s3\downloaded_packages
.rs.restartR()
NULL

Restarting R session...
reticulate::install_python()
Error in pyenv_bootstrap_windows() : 
  Please install git and ensure it is on your PATH
tensorflow::install_tensorflow()
Virtual environment "r-tensorflow" removed.
Using Python: C:/Users/Tapat1/AppData/Local/Programs/Python/Python310/python.exe
Creating virtual environment "r-tensorflow" ... 
+ "C:/Users/Tapat1/AppData/Local/Programs/Python/Python310/python.exe" -m venv "C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-tensorflow"
Done!
Installing packages: pip, wheel, setuptools
+ "C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-tensorflow/Scripts/python.exe" -m pip install --upgrade pip wheel setuptools
Requirement already satisfied: pip in c:\users\tapat1\onedrive - sysmc\documents\.virtualenvs\r-tensorflow\lib\site-packages (21.2.3)
Collecting pip
  Using cached pip-24.0-py3-none-any.whl (2.1 MB)
Collecting wheel
  Using cached wheel-0.43.0-py3-none-any.whl (65 kB)
Requirement already satisfied: setuptools in c:\users\tapat1\onedrive - sysmc\documents\.virtualenvs\r-tensorflow\lib\site-packages (57.4.0)
Collecting setuptools
  Using cached setuptools-69.5.1-py3-none-any.whl (894 kB)
Installing collected packages: wheel, setuptools, pip
  Attempting uninstall: setuptools
    Found existing installation: setuptools 57.4.0
    Uninstalling setuptools-57.4.0:
      Successfully uninstalled setuptools-57.4.0
  Attempting uninstall: pip
    Found existing installation: pip 21.2.3
    Uninstalling pip-21.2.3:
      Successfully uninstalled pip-21.2.3
Successfully installed pip-24.0 setuptools-69.5.1 wheel-0.43.0
Virtual environment 'r-tensorflow' successfully created.
Using virtual environment "r-tensorflow" ...
+ "C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-tensorflow/Scripts/python.exe" -m pip install --upgrade --no-user "tensorflow==2.16.*"
Collecting tensorflow==2.16.*
  Using cached tensorflow-2.16.1-cp310-cp310-win_amd64.whl.metadata (3.5 kB)
Collecting tensorflow-intel==2.16.1 (from tensorflow==2.16.*)
  Using cached tensorflow_intel-2.16.1-cp310-cp310-win_amd64.whl.metadata (5.0 kB)
Collecting absl-py>=1.0.0 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached absl_py-2.1.0-py3-none-any.whl.metadata (2.3 kB)
Collecting astunparse>=1.6.0 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached astunparse-1.6.3-py2.py3-none-any.whl.metadata (4.4 kB)
Collecting flatbuffers>=23.5.26 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached flatbuffers-24.3.25-py2.py3-none-any.whl.metadata (850 bytes)
Collecting gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached gast-0.5.4-py3-none-any.whl.metadata (1.3 kB)
Collecting google-pasta>=0.1.1 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached google_pasta-0.2.0-py3-none-any.whl.metadata (814 bytes)
Collecting h5py>=3.10.0 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached h5py-3.11.0-cp310-cp310-win_amd64.whl.metadata (2.5 kB)
Collecting libclang>=13.0.0 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached libclang-18.1.1-py2.py3-none-win_amd64.whl.metadata (5.3 kB)
Collecting ml-dtypes~=0.3.1 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached ml_dtypes-0.3.2-cp310-cp310-win_amd64.whl.metadata (20 kB)
Collecting opt-einsum>=2.3.2 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached opt_einsum-3.3.0-py3-none-any.whl.metadata (6.5 kB)
Collecting packaging (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached packaging-24.0-py3-none-any.whl.metadata (3.2 kB)
Collecting protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached protobuf-4.25.3-cp310-abi3-win_amd64.whl.metadata (541 bytes)
Collecting requests<3,>=2.21.0 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Requirement already satisfied: setuptools in c:\users\tapat1\onedrive - sysmc\documents\.virtualenvs\r-tensorflow\lib\site-packages (from tensorflow-intel==2.16.1->tensorflow==2.16.*) (69.5.1)
Collecting six>=1.12.0 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting termcolor>=1.1.0 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached termcolor-2.4.0-py3-none-any.whl.metadata (6.1 kB)
Collecting typing-extensions>=3.6.6 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached typing_extensions-4.11.0-py3-none-any.whl.metadata (3.0 kB)
Collecting wrapt>=1.11.0 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached wrapt-1.16.0-cp310-cp310-win_amd64.whl.metadata (6.8 kB)
Collecting grpcio<2.0,>=1.24.3 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached grpcio-1.63.0-cp310-cp310-win_amd64.whl.metadata (3.3 kB)
Collecting tensorboard<2.17,>=2.16 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached tensorboard-2.16.2-py3-none-any.whl.metadata (1.6 kB)
Collecting keras>=3.0.0 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached keras-3.3.3-py3-none-any.whl.metadata (5.7 kB)
Collecting tensorflow-io-gcs-filesystem>=0.23.1 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached tensorflow_io_gcs_filesystem-0.31.0-cp310-cp310-win_amd64.whl.metadata (14 kB)
Collecting numpy<2.0.0,>=1.23.5 (from tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached numpy-1.26.4-cp310-cp310-win_amd64.whl.metadata (61 kB)
Requirement already satisfied: wheel<1.0,>=0.23.0 in c:\users\tapat1\onedrive - sysmc\documents\.virtualenvs\r-tensorflow\lib\site-packages (from astunparse>=1.6.0->tensorflow-intel==2.16.1->tensorflow==2.16.*) (0.43.0)
Collecting rich (from keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached rich-13.7.1-py3-none-any.whl.metadata (18 kB)
Collecting namex (from keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached namex-0.0.8-py3-none-any.whl.metadata (246 bytes)
Collecting optree (from keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached optree-0.11.0-cp310-cp310-win_amd64.whl.metadata (46 kB)
Collecting charset-normalizer<4,>=2 (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl.metadata (34 kB)
Collecting idna<4,>=2.5 (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached idna-3.7-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests<3,>=2.21.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached certifi-2024.2.2-py3-none-any.whl.metadata (2.2 kB)
Collecting markdown>=2.6.8 (from tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached Markdown-3.6-py3-none-any.whl.metadata (7.0 kB)
Collecting tensorboard-data-server<0.8.0,>=0.7.0 (from tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached tensorboard_data_server-0.7.2-py3-none-any.whl.metadata (1.1 kB)
Collecting werkzeug>=1.0.1 (from tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached werkzeug-3.0.2-py3-none-any.whl.metadata (4.1 kB)
Collecting MarkupSafe>=2.1.1 (from werkzeug>=1.0.1->tensorboard<2.17,>=2.16->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached MarkupSafe-2.1.5-cp310-cp310-win_amd64.whl.metadata (3.1 kB)
Collecting markdown-it-py>=2.2.0 (from rich->keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached markdown_it_py-3.0.0-py3-none-any.whl.metadata (6.9 kB)
Collecting pygments<3.0.0,>=2.13.0 (from rich->keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached pygments-2.18.0-py3-none-any.whl.metadata (2.5 kB)
Collecting mdurl~=0.1 (from markdown-it-py>=2.2.0->rich->keras>=3.0.0->tensorflow-intel==2.16.1->tensorflow==2.16.*)
  Using cached mdurl-0.1.2-py3-none-any.whl.metadata (1.6 kB)
Using cached tensorflow-2.16.1-cp310-cp310-win_amd64.whl (2.1 kB)
Using cached tensorflow_intel-2.16.1-cp310-cp310-win_amd64.whl (376.9 MB)
Using cached absl_py-2.1.0-py3-none-any.whl (133 kB)
Using cached astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Using cached flatbuffers-24.3.25-py2.py3-none-any.whl (26 kB)
Using cached gast-0.5.4-py3-none-any.whl (19 kB)
Using cached google_pasta-0.2.0-py3-none-any.whl (57 kB)
Using cached grpcio-1.63.0-cp310-cp310-win_amd64.whl (3.9 MB)
Using cached h5py-3.11.0-cp310-cp310-win_amd64.whl (3.0 MB)
Using cached keras-3.3.3-py3-none-any.whl (1.1 MB)
Using cached libclang-18.1.1-py2.py3-none-win_amd64.whl (26.4 MB)
Using cached ml_dtypes-0.3.2-cp310-cp310-win_amd64.whl (127 kB)
Using cached numpy-1.26.4-cp310-cp310-win_amd64.whl (15.8 MB)
Using cached opt_einsum-3.3.0-py3-none-any.whl (65 kB)
Using cached protobuf-4.25.3-cp310-abi3-win_amd64.whl (413 kB)
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Using cached tensorboard-2.16.2-py3-none-any.whl (5.5 MB)
Using cached tensorflow_io_gcs_filesystem-0.31.0-cp310-cp310-win_amd64.whl (1.5 MB)
Using cached termcolor-2.4.0-py3-none-any.whl (7.7 kB)
Using cached typing_extensions-4.11.0-py3-none-any.whl (34 kB)
Using cached wrapt-1.16.0-cp310-cp310-win_amd64.whl (37 kB)
Using cached packaging-24.0-py3-none-any.whl (53 kB)
Using cached certifi-2024.2.2-py3-none-any.whl (163 kB)
Using cached charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl (100 kB)
Using cached idna-3.7-py3-none-any.whl (66 kB)
Using cached Markdown-3.6-py3-none-any.whl (105 kB)
Using cached tensorboard_data_server-0.7.2-py3-none-any.whl (2.4 kB)
Using cached urllib3-2.2.1-py3-none-any.whl (121 kB)
Using cached werkzeug-3.0.2-py3-none-any.whl (226 kB)
Using cached namex-0.0.8-py3-none-any.whl (5.8 kB)
Using cached optree-0.11.0-cp310-cp310-win_amd64.whl (243 kB)
Using cached rich-13.7.1-py3-none-any.whl (240 kB)
Using cached markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
Using cached MarkupSafe-2.1.5-cp310-cp310-win_amd64.whl (17 kB)
Using cached pygments-2.18.0-py3-none-any.whl (1.2 MB)
Using cached mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Installing collected packages: namex, libclang, flatbuffers, wrapt, urllib3, typing-extensions, termcolor, tensorflow-io-gcs-filesystem, tensorboard-data-server, six, pygments, protobuf, packaging, numpy, mdurl, MarkupSafe, markdown, idna, grpcio, gast, charset-normalizer, certifi, absl-py, werkzeug, requests, optree, opt-einsum, ml-dtypes, markdown-it-py, h5py, google-pasta, astunparse, tensorboard, rich, keras, tensorflow-intel, tensorflow
Successfully installed MarkupSafe-2.1.5 absl-py-2.1.0 astunparse-1.6.3 certifi-2024.2.2 charset-normalizer-3.3.2 flatbuffers-24.3.25 gast-0.5.4 google-pasta-0.2.0 grpcio-1.63.0 h5py-3.11.0 idna-3.7 keras-3.3.3 libclang-18.1.1 markdown-3.6 markdown-it-py-3.0.0 mdurl-0.1.2 ml-dtypes-0.3.2 namex-0.0.8 numpy-1.26.4 opt-einsum-3.3.0 optree-0.11.0 packaging-24.0 protobuf-4.25.3 pygments-2.18.0 requests-2.31.0 rich-13.7.1 six-1.16.0 tensorboard-2.16.2 tensorboard-data-server-0.7.2 tensorflow-2.16.1 tensorflow-intel-2.16.1 tensorflow-io-gcs-filesystem-0.31.0 termcolor-2.4.0 typing-extensions-4.11.0 urllib3-2.2.1 werkzeug-3.0.2 wrapt-1.16.0

Installation complete.

Restarting R session...
rbenel commented 2 months ago

After weeks of trying to install tensorflow on various windows computers I keep running into the same issues. They mainly arise when a Python package manager such as anaconda is installed on the computer, but not only.

I have narrowed it down to these some error messages that no matter which virtual environment I use or which binary .exe of Python I download (between Python3.8-3.11) keep repeating themselves.

As it is a windows computer I have seen various solutions for the SSL but they are linux solutions.

These are the most popular error messages: The Git Path, the SSL connection, and the Python exception

reticulate::install_python()
Error in pyenv_bootstrap_windows() : 
  Please install git and ensure it is on your PATH
install_tensorflow(envname = "r-tensorflow")
Using Python: C:/Users/Tapat1/anaconda3/python.exe
Creating virtual environment "r-reticulate" ... 
+ "C:/Users/Tapat1/anaconda3/python.exe" -m venv "C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-reticulate"
Done!
Installing packages: pip, wheel, setuptools
+ "C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-reticulate/Scripts/python.exe" -m pip install --upgrade pip wheel setuptools
Collecting pip
  Downloading pip-24.0-py3-none-any.whl (2.1 MB)
Collecting wheel
  Downloading wheel-0.43.0-py3-none-any.whl (65 kB)
Collecting setuptools
  Downloading setuptools-69.5.1-py3-none-any.whl (894 kB)
Installing collected packages: pip, wheel, setuptools
  Attempting uninstall: pip
    Found existing installation: pip 20.1.1
    Uninstalling pip-20.1.1:
      Successfully uninstalled pip-20.1.1
  Attempting uninstall: setuptools
    Found existing installation: setuptools 47.1.0
    Uninstalling setuptools-47.1.0:
      Successfully uninstalled setuptools-47.1.0
Successfully installed pip-24.0 setuptools-69.5.1 wheel-0.43.0
Installing packages: numpy
+ "C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-reticulate/Scripts/python.exe" -m pip install --upgrade --no-user numpy
Collecting numpy
  Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl.metadata (5.6 kB)
Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl (14.9 MB)
   ---------------------------------------- 14.9/14.9 MB 10.1 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-1.24.4
Virtual environment 'r-reticulate' successfully created.
Using Python: C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-reticulate/Scripts/python.exe
Creating virtual environment "r-tensorflow" ... 
+ "C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-reticulate/Scripts/python.exe" -m venv "C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-tensorflow"
Done!
Installing packages: pip, wheel, setuptools
+ "C:/Users/Tapat1/OneDrive - Sysmc/Documents/.virtualenvs/r-tensorflow/Scripts/python.exe" -m pip install --upgrade pip wheel setuptools
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='[pypi.org](http://pypi.org/)', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Requirement already up-to-date: pip in c:\users\tapat1\onedrive - sysmc\documents\.virtualenvs\r-tensorflow\lib\site-packages (20.1.1)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/wheel/
Could not fetch URL https://pypi.org/simple/wheel/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='[pypi.org](http://pypi.org/)', port=443): Max retries exceeded with url: /simple/wheel/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement wheel (from versions: none)
ERROR: No matching distribution found for wheel
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='[pypi.org](http://pypi.org/)', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Error: Error installing package(s): "pip", "wheel", "setuptools"
Python exception encountered:
 Traceback (most recent call last):
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
  File "C:\Users\moshek\AppData\Local\R\win-library\4.3\reticulate\python\rpytools\loader.py", line 120, in _hook
    return _find_and_load(name, import_)

We really want to be able to use tensorflow on a windows computer either using a python binary for a specific version or a virtual environment.
Thanks!

t-kalinowski commented 2 months ago

Thanks. A few notes:

rbenel commented 2 months ago

Hi! I can try to install Git, but I have official binaries of python installed as well, like mentioned in the tutorial between versions 3.8-3.10 and this doesn't seem to help.

I agree regarding the OneDrive, I have run into that issue before.

Please advise how to set up the installation using a python binary correctly.

Thanks!

t-kalinowski commented 2 months ago

Where is Git installed? Is that location on PATH? (In R, what does Sys.which("git") return). If git is not on the PATH, can you add it to PATH?

Where is Python installed? What does reticulate::virtualenv_starter(all = TRUE) find? virtualenv_starter() should find all Pythons installed in common and default locations, but if you have a custom location then you'll need to help point reticulate at it, or pass a path to TensorFlow explicitly.

To use a specific Python executable to create the "r-tensorflow" venv, you can supply a path to python_version, like this:

install_tensorflow(python_version = "/path/to/bin/python"`)

You can also set the R option reticulate.virtualenv.starter or the env var RETICULATE_VIRTUALENV_STARTER to a path where Pythons are installed, or a : delimited list of paths.

rbenel commented 1 month ago

Hi Tomasz,

I successfully installed Git using the default parameters and when I ran this line Sys.which("git") it returns "" and not a path for where PATH of Git.

I did however use install_tensorflow(python_version = "/path/to/bin/python") using my specific exectuatble and then the installation worked. I am not sure if this is related to the fact the reticulate can now use Git.

I have additional computers to install on so I hope this workaround will be a[appropriate for all!

Thank you so much for your time!

t-kalinowski commented 1 month ago

If Sys.which("git") return "", then git is not on your PATH.

If I remember correctly, the git installer provides an option to place it on the PATH for you? Rerunning the installer and checking the option might be the most accessible solution. You can also place the directory where git.exe is on PATH yourself. Here are two of the top google search results for "setting PATH windows" which at a glance look right to me:

https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows https://www.computerhope.com/issues/ch000549.htm