I'm experiencing the following error when trying to share the Matlab engine with Python:
Error using matlabfuture>result (line 87)
Python Error: EngineError: Unable to connect to MATLAB session 'Matlab_Engine_Test'.
Error in futureresult>result (line 67)
Error in __init__>connect_matlab (line 177)
Error in client>testing_output (line 204)
The code works by running a Matlab script that creates a Python Object. Then it calls the class method test_method():
a = py.py_lib.py_class;
The method test_method() attempts to connect to the Matlab engine and then create a variable in the workspace:
eng = matlab.engine.connect_matlab('Matlab_Engine_Test')
eng.workspace['temp'] = 1223
But the connection fails and produces the previously mentioned error.
Based on the documentation it looks to me like this should work. Anyone have any ideas?
EDIT: I should clarify why I'm building it this way instead of just having the Python method return a value as you'd expect.
I'm testing how to connect Python to the "active" workspace. In practice the method that will actually run is a callback function triggered by an API returning data that'll need to retuirn values to the workspace. The best way I can think is to add a variable to the workspace through the shared engine accessed through Python. (If anyone has better suggestions, I'm all ears).
So to test this out I just figured I'd do it without the callback and possible issues that could create and just use a test method I could call directly.