Why would py.importlib.import_module('keras') fail?
조회 수: 3 (최근 30일)
이전 댓글 표시
% 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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!