After install the matlabengine for python,This ERROR accured when i import matlab engine

22 Ansichten (letzte 30 Tage)
My python is ver3.7 and matlab is 2020a ,from the init.py in matlabengines it shows that this version is supported.
THEN I tried to copy the matlabengineforpython3_7.pyd from matlabroot/extern\engines\python\dist\matlab\engine\win64 to site-packages,the first moduleNotFoundError disappeared,but the rest errors still remained, how can i do with these error?

Antworten (1)

Daniel Souza
Daniel Souza am 2 Mai 2020
Bearbeitet: Daniel Souza am 2 Mai 2020
A very similar error happens when trying to install matlabengineforpython package from WSL pointing to a the installation folder of MATLAB for Windows. If that case, the following applies:
When you run
python setup.py install
from within a WSL terminal and with a valid Python environment, the package matlabengineforpython will be installed by adding the containing folder of matlabengineforpython3_7.pyd to sys.path.
See line #52 of "matlabroot/extern/engines/python/build/lib/matlab/engine/__init__.py"
sys.path.insert(0,engine_dir)
Then when you try to import matlab.engine from a Python script within WSL, importing fails so a similar error happens because *.pyd only work on Python for Windows.
If you actually had MATLAB for Linux installed inside WSL, I bet the installation of matlabengineforpython would work flawlessly. A possible workaround to this problem then is to copy matlabengineforpython3_7.so from your corresponding MATLAB for Linux folder to "matlabroot/extern/engines/python/dist/matlab/engine/win64".

Kategorien

Mehr zu Call MATLAB from Python finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by