Skip to content

[R-pkg-devel] How to solve this error while running python script in R environment?

3 messages · KABILAN S, Michael Dewey, Ivan Krylov

#
When I am creating the R package based on the python script, I am getting the below error while checking the package.


* checking examples ... [60s] ERROR
Running examples in 'transformerForecasting-Ex.R' failed
The error most likely occurred in:
Error: Valid installation of TensorFlow not found.

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

Python exception encountered:
 Traceback (most recent call last):
  File "D:\RCompile\CRANpkg\lib\4.5\reticulate\python\rpytools\loader.py", line 122, in _find_and_load_hook
    return _run_hook(name, _hook)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\RCompile\CRANpkg\lib\4.5\reticulate\python\rpytools\loader.py", line 96, in _run_hook
    module = hook()
             ^^^^^^
  File "D:\RCompile\CRANpkg\lib\4.5\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.
Execution halted

How to solve this?
#
Have you got tensorflow installed somewhere where R knows about it?

Michael
On 07/02/2025 06:51, KABILAN S wrote:

  
    
#
? Fri, 7 Feb 2025 06:51:27 +0000
KABILAN S <kabilan151414 at gmail.com> ?????:
I'm afraid you'll have to wrap your examples in checks for
py_module_available(...):
https://stat.ethz.ch/pipermail/r-package-devel/2024q3/011076.html