matlab python engine module not recognized

5 visualizaciones (últimos 30 días)
Shiping Yi
Shiping Yi el 29 de Jul. de 2019
Respondida: Meet el 17 de En. de 2025
I am having trouble using the matlab python engine. I tried this piece of code from the mathworks website:
import matlab.engine
if __name__ == '__main__':
eng = matlab.engine.start_matlab()
x = 4.0
eng.workspace['y'] = x
a = eng.eval('sqrt(y)')
print(a)
pass
But pycharm is giving me an error saying "ModuleNotFoundError: No module named 'matlab.engine'; 'matlab' is not a package". I am using python 3.6 and matlab 2018. I saw that these are the supported versions on website, I saw a similar post about this problem but I can't even run my program from python command line. I also can't find teh matlab.py in my python site-packages, although I have the matlab folder in packages.

Respuestas (1)

Meet
Meet el 17 de En. de 2025
Hi Shiping,
To resolve this issue, you need to install the MATLAB Engine API for Python:
First ensure that you have correct version of python installed and accessible using command line.
Then open a command prompt and navigate to the MATLAB engine directory:
cd "matlabroot\extern\engines\python"
Replace 'matlabroot' with your MATLAB installation directory.
Install MATLAB API using 'pip' command:
python -m pip install .
To get the detailed instructions on the same, please follow this documentation link:

Categorías

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

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