matlab/simulink+tensorflow problem
My MATLAB can connect to Python and execute Python statements, but it encounters an error when importing TensorFlow. How can I resolve this?
In the MATLAB command line, when I enter:
py.importlib.import_module(‘tensorflow’)
an error occurs:
“error to use pywrap_tensorflow><module> (line 88)
Python error ImportError: Traceback (most recent call last):
File "C:UsersLENOVO.condaenvsmatlab_testlibsite-packagestensorflowpythonpywrap_tensorflow.py", line 73, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 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.
Error in __init__><module> (line 40)
Error in <frozen importlib>_call_with_frames_removed (line 228)
Error in <frozen importlib>exec_module (line 850)
Error in <frozen importlib>_load_unlocked (line 680)
Error in <frozen importlib>_find_and_load_unlocked (line 986)
Error in <frozen importlib>_find_and_load (line 1007)
Error in <frozen importlib>_gcd_import (line 1030)
Error in __init__>import_module (line 127)
”
My matlab version is R2024a, python== 3.9, tensorflow-cpu==2.19
When I import TensorFlow in the Python command line, there is no problem, but when I do so in MATLAB, the above error occurs.
I’ve tried a few solutions, but none of them worked:
Install Microsoft Visual C++ Redistributable
Switch tensorflow from GPU version to CPU version
Use Anaconda to isolate dependencies for different projects.
please help me !!!!!My MATLAB can connect to Python and execute Python statements, but it encounters an error when importing TensorFlow. How can I resolve this?
In the MATLAB command line, when I enter:
py.importlib.import_module(‘tensorflow’)
an error occurs:
“error to use pywrap_tensorflow><module> (line 88)
Python error ImportError: Traceback (most recent call last):
File "C:UsersLENOVO.condaenvsmatlab_testlibsite-packagestensorflowpythonpywrap_tensorflow.py", line 73, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 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.
Error in __init__><module> (line 40)
Error in <frozen importlib>_call_with_frames_removed (line 228)
Error in <frozen importlib>exec_module (line 850)
Error in <frozen importlib>_load_unlocked (line 680)
Error in <frozen importlib>_find_and_load_unlocked (line 986)
Error in <frozen importlib>_find_and_load (line 1007)
Error in <frozen importlib>_gcd_import (line 1030)
Error in __init__>import_module (line 127)
”
My matlab version is R2024a, python== 3.9, tensorflow-cpu==2.19
When I import TensorFlow in the Python command line, there is no problem, but when I do so in MATLAB, the above error occurs.
I’ve tried a few solutions, but none of them worked:
Install Microsoft Visual C++ Redistributable
Switch tensorflow from GPU version to CPU version
Use Anaconda to isolate dependencies for different projects.
please help me !!!!! My MATLAB can connect to Python and execute Python statements, but it encounters an error when importing TensorFlow. How can I resolve this?
In the MATLAB command line, when I enter:
py.importlib.import_module(‘tensorflow’)
an error occurs:
“error to use pywrap_tensorflow><module> (line 88)
Python error ImportError: Traceback (most recent call last):
File "C:UsersLENOVO.condaenvsmatlab_testlibsite-packagestensorflowpythonpywrap_tensorflow.py", line 73, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 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.
Error in __init__><module> (line 40)
Error in <frozen importlib>_call_with_frames_removed (line 228)
Error in <frozen importlib>exec_module (line 850)
Error in <frozen importlib>_load_unlocked (line 680)
Error in <frozen importlib>_find_and_load_unlocked (line 986)
Error in <frozen importlib>_find_and_load (line 1007)
Error in <frozen importlib>_gcd_import (line 1030)
Error in __init__>import_module (line 127)
”
My matlab version is R2024a, python== 3.9, tensorflow-cpu==2.19
When I import TensorFlow in the Python command line, there is no problem, but when I do so in MATLAB, the above error occurs.
I’ve tried a few solutions, but none of them worked:
Install Microsoft Visual C++ Redistributable
Switch tensorflow from GPU version to CPU version
Use Anaconda to isolate dependencies for different projects.
please help me !!!!! deep learning, tensorflow MATLAB Answers — New Questions









