-
Notifications
You must be signed in to change notification settings - Fork 284
Description
Description
I am using R (keras3 + reticulate) on Windows.
When TensorFlow is initialized via reticulate, I consistently encounter
"DLL load failed while importing _pywrap_tensorflow_internal".
This happens when calling keras3::dataset_mnist() or importing tensorflow
via reticulate.
Reproducible example
library(reticulate)
library(keras3)
mnist <- dataset_mnist()
reticulate::py_config()
python: C:/Users/Administrator/AppData/Local/R/cache/R/reticulate/uv/cache/archive-v0/HLPRwwBf27sR11YLimOxx/Scripts/python.exe
libpython: C:/Users/Administrator/AppData/Local/R/cache/R/reticulate/uv/python/cpython-3.12.12-windows-x86_64-none/python312.dll
pythonhome: C:/Users/Administrator/AppData/Local/R/cache/R/reticulate/uv/cache/archive-v0/HLPRwwBf27sR11YLimOxx
virtualenv: C:/Users/Administrator/AppData/Local/R/cache/R/reticulate/uv/cache/archive-v0/HLPRwwBf27sR11YLimOxx/Scripts/activate_this.py
version: 3.12.12 (main, Dec 9 2025, 19:02:55) [MSC v.1944 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/Administrator/AppData/Local/R/cache/R/reticulate/uv/cache/archive-v0/HLPRwwBf27sR11YLimOxx/Lib/site-packages/numpy
numpy_version: 1.26.4
keras: C:\Users\Administrator\AppData\Local\R\cache\R\reticulate\uv\cache\archive-v0\HLPRwwBf27sR11YLimOxx\Lib\site-packages\keras
NOTE: Python version was forced by py_require()
when i run code mnist <- dataset_mnist() always tell me the below infos:
Error: ImportError: Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\R\cache\R\reticulate\uv\cache\archive-v0\HLPRwwBf27sR11YLimOxx\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 73, in
<...truncated...> ^^^^^^
File "C:\Users\Administrator\AppData\Local\R\win-library\4.5\reticulate\python\rpytools\loader.py", line 120, in _hook
return find_and_load(name, import)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The dynamic link library (DLL) initialization routine failed.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors for some common causes and solutions.
If you need help, create an issue at https://github.com/tensorflow/tensorflow/issues and include the entire stack trace above this error message.
Run reticulate::py_last_error() for details.