Unable to import Tensorflow, keras libraries using python interface in Matlab
Mostrar comentarios más antiguos
Hello Everyone,
I created a conda vitual environment and installed tensorflow 2.0. I am using Matlab 2018b version. I am able to import other libraries such as numpy, pandas, scikit-learn. but unable to import tensorflow 2.0 using py.importlib.import_module('tensorflow') command and got the below mentioned error:
Error using __init__><module> (line 40)
Python Error: ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not
a package
Error in __init__><module> (line 98)
from tensorflow_core import *
Error in <frozen importlib>_call_with_frames_removed (line 219)
Error in <frozen importlib>exec_module (line 678)
Error in <frozen importlib>_load_unlocked (line 665)
Error in <frozen importlib>_find_and_load_unlocked (line 955)
Error in <frozen importlib>_find_and_load (line 971)
Error in <frozen importlib>_gcd_import (line 994)
Error in __init__>import_module (line 126)
return _bootstrap._gcd_import(name[level:], package, level)
As a workaround, I created a new virtual environment and installed tensorflow 1.2.1 and keras 1.0.7. tensorflow 1.2.1 is getting imported in matlab but getting the below mentioned error while trying to import keras 1.0.7:
>> py.importlib.import_module('keras')
Error using __init__><module> (line 60)
Python Error: AttributeError: 'NoneType' object has no attribute 'write'
Error in __init__><module> (line 2)
from . import backend
Error in <frozen importlib>_call_with_frames_removed (line 219)
Error in <frozen importlib>exec_module (line 678)
Error in <frozen importlib>_load_unlocked (line 665)
Error in <frozen importlib>_find_and_load_unlocked (line 955)
Error in <frozen importlib>_find_and_load (line 971)
Error in <frozen importlib>_gcd_import (line 994)
Error in __init__>import_module (line 126)
return _bootstrap._gcd_import(name[level:], package, level)
Kindly someone help me in fixing the issue.
Thanks & Regards,
Chaitanya Gogineni
6 comentarios
chaitanya gogineni
el 13 de Dic. de 2019
Elif Ecem Bas
el 2 de Mzo. de 2020
I really wonder wether this issue solved or not?
Nitesh Kumar
el 4 de Ag. de 2020
@Chaitanya, Were you able to solve this issue?
Shantak Singh
el 14 de Ag. de 2020
I also face the same issue
yassine kebbati
el 30 de Sept. de 2020
no one found a solution to this?
Abdelwahab Afifi
el 14 de Feb. de 2021
any solution?
Respuestas (1)
Patrick Staehli
el 6 de En. de 2021
1 voto
Just start matlab from the anaconda console by typing matlab
Categorías
Más información sobre Call Python from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!