I am trying to run Matlab code using Python. I tried to follow the instructions given on this Mathworks page.
When trying to import Matlab though Python, it was installed using pip install matlab
.
However, importing matlab.engine
gives the error No module named 'matlab.engine'; 'matlab' is not a package
. It cannot be installed using pip install engine
either.
How can I get the code running? The Python code I'm running is as below:
import matlab.engine
eng = matlab.engine.start_matlab()
eng.triarea(nargout=0)
Python version - 3.5
Matlab version - 8.5.0.197613 (R2015a)
You need to install the Matlab Engine for Python, and it cannot be installed using pip. Try the instructions listed here. I have listed the instructions briefly below:
matlabroot
command within Matlab to find it.cd "matlabroot\extern\engines\python"
(In Windows)python setup.py install