ewiger / mlab

Mlab is a high-level python to Matlab® bridge that lets Matlab look like a normal python library.
MIT License
74 stars 23 forks source link

mlab.matlabpipe.MatlabConnectionError: timeout #9

Open ruozhichen opened 7 years ago

ruozhichen commented 7 years ago

When I executed the following commands, trying to call matlab function, it failed and the error trace is given at the end. from mlab.releases import latest_release as matlab matlab.plot([1,2,3,4,5],-'o')

It happened in Ubuntu. And I tested mlab in Windows before, it succeeded. So I don't know why it doesn't work in Ubuntu, I try to solve it but found nothing, I will be appreciated If anyone has some suggestions. If you have solved it before or know this error, please tell me.

Error:
File "/usr/local/lib/python2.7/site-packages/mlab/mlabwrap.py", line 607, in mlab_command return self._do(name, *args, **update({'nout':nout}, kwargs)) File "/usr/local/lib/python2.7/site-packages/mlab/mlabwrap.py", line 547, in _do res = self._get_values(resSL) File "/usr/local/lib/python2.7/site-packages/mlab/mlabwrap.py", line 483, in _get_values res.append(self._get(varname)) File "/usr/local/lib/python2.7/site-packages/mlab/mlabwrap.py", line 568, in _get vartype = self._var_type(varname) File "/usr/local/lib/python2.7/site-packages/mlab/mlabwrap.py", line 436, in _var_type res_type = mlabraw.get(self._session, "TMP_CLS__") File "/usr/local/lib/python2.7/site-packages/mlab/mlabraw.py", line 72, in get return matlab.get(var_name) File "/usr/local/lib/python2.7/site-packages/mlab/matlabpipe.py", line 250, in get self._read_until('start_binary\n', on_new_output=on_new_output) File "/usr/local/lib/python2.7/site-packages/mlab/matlabpipe.py", line 294, in _read_until raise MatlabConnectionError('timeout') mlab.matlabpipe.MatlabConnectionError:timeout.

jimmy-dq commented 7 years ago

@ruozhichen HI, have you solved this problem ? I face the same problem.

ruozhichen commented 7 years ago

@handworker
Sorry,I still not find a solution. However, I use another way to call matlab from python. You can choose matlab engine for python. install: http://cn.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html how to call matlab script: http://cn.mathworks.com/help/matlab/matlab_external/call-user-script-and-function-from-python.html Hope this could help you.

jimmy-dq commented 7 years ago

@ruozhichen Thanks!

andrewminer commented 6 years ago

I've run into this problem as well, and, in my case, it was because the function I was calling was running into an error, and therefore never returned. This caused the pipe to never find the ___MATLAB_PIPE_COMMAND_ENDED___ terminator it was waiting for, and thus, the timeout message.

I diagnosed the problem my adding print "output_tail: %s" % (output_tail) just before this line so I could see exactly what was going on.

I'd suggest that the fix is to modify that _read_until function to look for errors and to throw an exception if one is returned.