Python Error: ImportError: No module named engine

1 visualización (últimos 30 días)
Joao Paulo Oliveira Fernandes
Joao Paulo Oliveira Fernandes el 3 de Abr. de 2019
Respondida: Davide Giovenzana el 3 de Nov. de 2020
I'm trying to import matlab.engine module in a .py file that's going to be executed inside Matlab. Here is the process and files:
My test.py file:
# test.py
import matlab.engine
On Matlab, I do:
>> mod = py.importlib.import_module('test');
>> py.reload(mod)
Error msg:
Error using test><module> (line 1)
Python Error: ImportError: No module named engine
In my python file, even inside Matlab, when I just import matlab module, it works, but when I try to import engine, it fails...
How can I import matlab.engine module inside Matlab?
Obs.:
Module matlab imported inside Matlab:
>> py.importlib.import_module('matlab')
ans =
Python module with properties:
Buffer: [1×1 py.type]
<module 'libmwbuffer' from 'C:\MATLAB\R2018b\bin\win64\libmwbuffer.pyd'>
Module matlab imported outside Matlab (cmd.exe, for instance):
>>> import matlab
>>> matlab
<module 'matlab' from 'C:\Python27\lib\site-packages\matlab\__init__.pyc'>
Is it a conflict?
The import matlab.engine works outside matlab, if I run in the cmd.exe, for example, it works.
Using Matlab 2018b, Python 2.7. Everything x64. Windows 7.

Respuestas (3)

Will Lee
Will Lee el 30 de Mayo de 2019
I have the same issue.Do you have solved this issue?

Will Lee
Will Lee el 31 de Mayo de 2019
I have solved the issue.The issue caused by a script named 'matlab.py' in the folder which the script runs in.It's my mistake,i take half of day for it.

Davide Giovenzana
Davide Giovenzana el 3 de Nov. de 2020
I had the same issue with Matlab 2018b, but the issue has been solved in a later version (currently using 2020b).
Can anyone from Mathworks expain what's changed?

Categorías

Más información sobre Call MATLAB from Python en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by