フィルターのクリア

Why would py.importl​ib.import_​module('ke​ras') fail?

5 ビュー (過去 30 日間)
Dominik Mattioli
Dominik Mattioli 2019 年 6 月 18 日
コメント済み: Dominik Mattioli 2020 年 4 月 14 日
% 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 件のコメント
Nitesh Kumar
Nitesh Kumar 2020 年 4 月 14 日
Hi, Were you able to solvce this issue? I am having similar issues.
Dominik Mattioli
Dominik Mattioli 2020 年 4 月 14 日
No, unfortunately not. I believe it is/was an issue with the MATLAB version that I was using (2018a?), where MATLAB had not yet implemented a capability for the type of layers that I was trying to use. It may be fixed with the newer version (2020a).

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by