Unable to import Tensorflow, keras libraries using python interface in Matlab

9 vues (au cours des 30 derniers jours)
chaitanya gogineni
chaitanya gogineni le 10 Déc 2019
Commenté : Abdelwahab Afifi le 14 Fév 2021
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 commentaires
yassine kebbati
yassine kebbati le 30 Sep 2020
no one found a solution to this?

Connectez-vous pour commenter.

Réponses (1)

Patrick Staehli
Patrick Staehli le 6 Jan 2021
Just start matlab from the anaconda console by typing matlab

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by