_ matlab.engine.start_matlab() _function starts a MATLAB session. So, if it is taking too long, it is possible that MATLAB itself takes few seconds to start.
matlab.engine.start_matlab() always starts a new MATLAB process, and returns Python variable eng, which is a MatlabEngine object for communicating with the MATLAB process.
You can quickly test the same on a Windows enviroment.
When you call _matlab.engine.start_matlab(), _it will start a new MATLAB process always.
If no argument is passed, it will open a background process.
To confirm that this functions starts a new session always (even though MATLAB session is currently running), please start using "-desktop" option-
eng = matlab.engine.start_matlab("-desktop")
You will see that a new MATLAB Session has been started.
If no option is used, you can see MATLAB in background process.
Run the following command in MATLAB command prompt
>> which -all startup.m
It will show you if you are using any startup file.
Sometime startup file can cause delay.
If you see any startup.m file, try to rename it and try connecting MATLAB engine from Python.
Best Answer