我点击此链接在 python 中运行 matlab 代码:Running Matlab using Python gives 'No module named matlab.engine' error
我收到错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\XYZ\AppData\Local\Programs\Python\Python36\lib\site-packages\matlab\engine\matlabengine.py", line 71, in __call___stderr, feval=True).result()
File "C:\Users\XYZ\AppData\Local\Programs\Python\Python36\lib\site-packages\matlab\engine\futureresult.py", line 67, in result
return self.__future.result(timeout)
File "C:\Users\XYZ\AppData\Local\Programs\Python\Python36\lib\site-packages\matlab\engine\fevalfuture.py", line 82, in result
self._result = pythonengine.getFEvalResult(self._future,self._nargout, None,out=self._out, err=self._err)
matlab.engine.EngineError: MATLAB function cannot be evaluated
我正在使用 Python 3.6 windows 7, 64 位 Matlab R2018b版本
我刚刚在matlab中编写了一个简单的函数并将文件保存为demo.m 代码在这里:
printk();
function printk()
fprintf(' Hello world!');
end
并将文件另存为 demo.mat
Python 空闲:
import matlab.engine
eng = matlab.engine.start_matlab()
eng.demo(nargout=0)
任何人都可以帮忙吗?我需要迁移 python 中的一大堆代码。任何其他可能的方式将不胜感激。谢谢。
最佳答案
如果您有 64 位 matlab,则需要 64 位 python。
也许您正在寻找类似的东西: https://github.com/Wilhox/Matlab-Shell-for-python.git
关于python - 在 python 中运行 matlab 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53598110/