cpbotha / mlabwrap-purepy

Pure Python version of the mlabwrap Python to Matlab bridge
28 stars 3 forks source link

Timeout error on start #1

Open mfitzp opened 10 years ago

mfitzp commented 10 years ago

I'm trying to get this working on Matlab 2011a (Student Version) and keep hitting a timeout error on startup:

Python 2.7.6 (default, Nov 21 2013, 14:45:53) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mlabwrap
>>> mlab = mlabwrap.init()
Found version: 2011a at /Applications/MATLAB_R2011a_Student.app/bin/matlab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mlabwrap/mlabwrap.py", line 763, in init
    _mlab = MlabWrap(matlab_binary_path, matlab_version)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mlabwrap/mlabwrap.py", line 442, in __init__
    self._session = mlabraw.open(matlab_binary_path)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mlabwrap/mlabraw.py", line 28, in open
    ret.open()
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mlabwrap/matlabpipe.py", line 200, in open
    self._sync_output()
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mlabwrap/matlabpipe.py", line 447, in _sync_output
    return self._read_until(self.expected_output_end, on_new_output)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mlabwrap/matlabpipe.py", line 384, in _read_until
    raise MatlabConnectionError('timeout')
mlabwrap.matlabpipe.MatlabConnectionError: timeout

The output when starting Matlab from the command line directly is as follows:

mxf793@COLMDS-MIBR307B ~ $ matlab -nodesktop -nojvm

                                                                             < M A T L A B (R) >
                                                                   Copyright 1984-2010 The MathWorks, Inc.
                                                                 Version 7.12.0.635 (R2011a) 64-bit (maci64)
                                                                                March 18, 2011

Warning: Duplicate directory name: /Users/mxf793/matlab. 
Warning: Name is nonexistent or not a directory: /usr/local/mysql/lib. 

  To get started, type one of these: helpwin, helpdesk, or demo.
  For product information, visit www.mathworks.com.

  Student License -- for use in conjunction with courses offered at a 
  degree-granting institution.  Professional and commercial use prohibited.

EDU>> 

Any suggestions?

mfitzp commented 10 years ago

The issue appears to be in mlabpipe.py where it is searching for the end-marker. One student versions the prompt shows EDU. Changing the line as follows makes it work:

    self.expected_output_end = '%s\nEDU>> ' % self.command_end_string

I'll work out a way to make this work on both student/normal Matlab and make a PR.