从Python运行MATLAB [英] Running MATLAB from Python
问题描述
我正在自学使用python和matlab进行一些编程.而且我需要运行用matlab在python中编写的几个函数.
I'm teaching myself a little bit of programming in python and also matlab. And I need to run a couple of functions I wrote in python with matlab.
我遵循了pymatlab和python(x,y)的基本安装说明.当我尝试使用以下代码创建MATLAB会话时:
I've followed the basic install instructions for pymatlab and python(x,y). When I try to create a MATLAB session with the following code:
import pymatlab
session = pymatlab.session_factory()
我收到以下错误:
Exception AttributeError: "'MatlabSession' object has no attribute 'engine'" in <bound method MatlabSession.__del__ of <pymatlab.matlab.MatlabSession object at 0x03654AF0>> ignored
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
session = pymatlab.session_factory()
File "C:\Python27\lib\site-packages\pymatlab\sessionfactory.py", line 51, in session_factory
session = MatlabSession(path=basedir,bufsize=output_buffer_size)
TypeError: __init__() got an unexpected keyword argument 'path'
请帮助!
推荐答案
这是Windows平台中需要修复的错误.您可以打开文件"C:\ Python27 \ lib \ site-packages \ pymatlab \ sessionfactory.py"并找到第51行,并删除参数前缀"path ="
It's a bug need fixed in windows platform. you can open the file "C:\Python27\lib\site-packages\pymatlab\sessionfactory.py" and locate the line 51, remove argument prefix "path="
MatlabSession(path=basedir,bufsize=output_buffer_size)
更改为
MatlabSession(basedir,bufsize=output_buffer_size)
那么您就可以享受pymatlab了.
Then you can enjoy your pymatlab.
这篇关于从Python运行MATLAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!