Python calls MATLAB method

After running the python setup.py install command in the MATLAB installation location ( C:\Program Files\MATLAB\R2021b\extern\engines\python ), if the following prompt still appears, you can directly copy the folder.

 

1) import matlab.engine时ImportError: No module named matlab.engine

2) OSError: MATLAB Engine for Python supports Python version 2.x, 3.x and 3.x, but your version of Python is 3.x

The first step is to copy the folder matlab in the MATLAB installation location ( C:\Program Files\MATLAB\R2021b\extern\engines\python\dist )

In the second step, paste the folder matlab in the anaconda installation location ( C:\XXX\XXX\Anaconda3\Lib\site-packages )

This method does not require any command line manipulation


If there is a version problem, you can enter the subdirectory engine under the copied matlab folder , and open the file __init__.py

 On line 31 of the file, it represents the python version supported by this version of MATLAB

Guess you like

Origin blog.csdn.net/Cecidit_824/article/details/122810014