Task: Call a function from Matlab 2013b using Python 3.x on Windows 7 (all x64).
Question: Is there a Python package that allows me to do that?
I already tried:
but none of these work with the configuration given above.
Any information about a working configuration using Python 3.x is appreciated.
If you need more detailed information, please let me know.
Update: I am currently trying to get this working using Matlab2011b and Pyhton 2.7 as these seem to be the most used Versions. For now i am stuck at the following:
python-matlab-bridge I can import the module without problems but as soon as is start a Session a Matlab Command Window pops up and nothing else happens. The Python Window shows:
Starting MATLAB on ZMQ socket tcp://127.0.0.1:55555
Send 'exit' command to kill the server
............................................................Matlab session timed
out after 60 seconds
MATLAB failed to start
Press any key to continue . . .
This happens every single time and no error is given.
mlabwrap I tried to install mlabwrap using this guide. On typing 'python setup.py install' a Matlab Command Window pops up and again nothing happens. If i close the Command Window the Python output shows:
WINDOWS SPECIFIC ISSUE? Unable to remove c:\users\martin\appdata\local\temp\tmp1
y2kdk; please delete it manually
[Error 32] Der Prozess kann nicht auf die Datei zugreifen, da sie von einem ande
ren Prozess verwendet wird: 'c:\\users\\martin\\appdata\\local\\temp\\tmp1y2kdk'
INSTALL ABORT: 'matlab -nodesktop -nosplash -wait -r "fid = fopen(\'c:\\users\\m
artin\\appdata\\local\\temp\\tmp1y2kdk\', \'wt\');fprintf(fid, \'%s%c%s%c%s%c\',
version, 10, matlabroot, 10, computer, 10);fclose(fid); quit"' RETURNED ERROR C
ODE -805306369
PLEASE MAKE SURE matlab IS IN YOUR PATH!
My %Path%
looks like this (only the important parts ;):
D:\MATLAB\R2011b\bin;C:\Program Files\ZeroMQ 4.0.4\lib;D:\Python27;D:\Python27\scripts;D:\MATLAB\R2011b\runtime\win64;D:\MATLAB\R2011b\extern\lib\win64\microsoft;D:\MATLAB\R2011b\bin\win64
Any help to get any connection between Matlab and Python on Windows is appreciated! I really can´t see why none of this is working...
Update2: I can install mlabwrap now but i can´t start it. When i try to import mlabwrap a Matlab Command Window opens up and closes after a minute. The Python output is:
>>> import mlabwrap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python27\lib\site-packages\mlabwrap.py", line 645, in <module>
mlab = MlabWrap()
File "D:\Python27\lib\site-packages\mlabwrap.py", line 405, in __init__
self._session = mlabraw.open(os.getenv("MLABRAW_CMD_STR", ""))
mlabraw.error: Unable to start MATLAB(TM) engine
I double checked that the engdemo from Matlab is working.
I now got it working using python-matlab-bridge. I converted it by hand to Python3 and the changes have been merged into the official repo so it should work out of the box now.
If you get an error that 'messenger init' could not be found, make sure that Lib\site-packages\pymatbridge\matlab
is in your PATH
.
If you have any questions or additional information fell free to comment this answer and i will add it to help users get started with python-matlab-bridge.