When Python and matlab mixed, encountered a problem: ImportError: No module named matlab.engine "solution reprint

from https://blog.csdn.net/william_hehe/article/details/82828873

Note: the current understanding, matlab supported version 2.7,3.3, 3.4, 3.5, 3.6 is not supported. (3.5.5 effective pro-test)

Steps are as follows:

1. Anaconda installation using the virtual environment py35, as follows:

Create -name py35 Python = Conda 3.5 of

2. After creating, can be activated by the following method:

py35 of an activate
3. (option) by the following name to view the current python version environment

python
4. After create python3.5 environment, next to matlab environment configuration.

5. In the matlab installation path, find the file directory "./extern/engines/python", as shown below (red marquee original document file is present):

 

Under 6.win10 system, win + r open cmd, switch a current path to the file in the path 5.

7. sequentially performing the following command line in the path 6:

Build-Base --build setup.py Python = "the builddir" the install

Python setup.py the install --prefix = "INSTALLDIR"

Python setup.py --build Build-Base = "the builddir" the install --prefix = "INSTALLDIR"

Python setup.py install --user
8. When execution is completed, as shown in the figure above to generate the file folder.

9. Test the code:

#coding=utf-8
import matlab.engine
from numpy import *

if __name__ == '__main__':
eng = matlab.engine.start_matlab('MATLAB_R2016b')
A = matlab.double([[1,2],[5,6]])
print(type(A),A.size,A)
print(eng.eig(A))
eng.quit()
pass
结果如下:

 

10. Complete call it a day!


----------------
Disclaimer: This article is CSDN bloggers "down & pick up the wrench keyboard 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/william_hehe/article/details/82828873

Guess you like

Origin www.cnblogs.com/gisalameda/p/11518246.html