Matlab Python module import __future__

5 views (last 30 days)
leonolovich
leonolovich on 21 Mar 2018
Edited: leonolovich on 21 Mar 2018
Hello - I am trying to call a Python module from within Matlab that generates a Python Error as follows. Python Error: ImportError: cannot import name np_utils
In Matlab, I am running the code: py.importlib.
P = py.sys.path;
insert(P,int32(0),'/home/thisisme/anaconda3/envs/keras_testing/lib/python2.7/site-packages/keras');
import_module('test_detector');
Most imports are processed correctly, but the code errors out down a nested function which reads as follows:
from __future__ import absolute_import
from . import np_utils
If I, however, change the 'from . import np_utils' line to simply 'import np_utils', it works fine. I would change this if I could, but this is part of the Keras library and I do not want to touch that library. I believe I should be able to import that library without a problem. It is as if Matlab doesnt know what 'from . ' means.
Any thoughts on how to resolve this?
Using: MATLAB 2017b 64-bit Python 2.7.14 64-bit Linux 64bit

Answers (0)

Community Treasure Hunt

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

Start Hunting!