Why would py.importlib.import_module('keras') fail?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
% Specify Python Executable Library.
pcPythonExe = 'C:\Users\dmattioli\AppData\Local\Programs\Python\Python37\python.exe';
[ver, exec, loaded] = pyversion(pcPythonExe);
% Ensure python-matlab integration code is on matlab path.
pyFolder = fullfile(matlabroot, 'toolbox', 'matlab', 'external', 'interfaces', 'python');
addpath(pyFolder);
insert(py.sys.path, int64(0), pyFolder);
% Add relevant libaries' directory to python path.
otherpyFolder = 'C:\Users\dmattioli\.PyCharm2019.1\system\python_stubs\278535617';
insert(py.sys.path, int64(0), otherpyFolder)
>> pyversion
version: '3.7'
executable: 'C:\Users\dmattioli\AppData\Local\Programs\Python\Python37\python.exe'
library: 'C:\Users\dmattioli\AppData\Local\Programs\Python\Python37\python37.dll'
home: 'C:\Users\dmattioli\AppData\Local\Programs\Python\Python37'
isloaded: 1
The error occurs in the following code (test3):
test0 = py.importlib.import_module('numpy') % Succeeds
test1 = py.importlib.import_module('matplotllib') % Succeeds
test2 = py.importlib.import_module('tensorflow') % Succeeds
test3 = py.importlib.import_module('keras') % Fails
>> test3 = py.importlib.import_module('keras')
Error using __init__><module> (line 88)
Python Error: AttributeError: 'NoneType' object has no attribute 'write'
Error in conv_utils><module> (line 9)
from .. import backend as K
Error in __init__><module> (line 6)
from . import conv_utils
Error in __init__><module> (line 3)
from . import utils
Error in <frozen importlib>_call_with_frames_removed (line 219)
Error in <frozen importlib>exec_module (line 728)
Error in <frozen importlib>_load_unlocked (line 677)
Error in <frozen importlib>_find_and_load_unlocked (line 967)
Error in <frozen importlib>_find_and_load (line 983)
Error in <frozen importlib>_gcd_import (line 1006)
Error in __init__>import_module (line 127)
return _bootstrap._gcd_import(name[level:], package, level)
2 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!