MATLAB: Is “mwpython” required to run Python packages on Mac OS

macosMATLAB Compiler SDKmwpython

I am using Compiler SDK to build a python library on Mac, so the program must be launched with the "mwpython" command instead of launching it with "python". Why do we have to wrap python commands like this on Mac machines?

Best Answer

macOS does not allow to call graphics code from the main thread, "mwpython" is a way to get around this macOS limitation. Without this, it will not let you run such python packages generated by the MATLAB Compiler SDK.
"mwpython" is bash script located in "matlabroot/bin". This script is used for setting up all the necessary environment for MATLAB Compiler Runtime (MCR). Aside from setting up the environment for MCR, it will launch the default python for you (the default python is what will be launched in the current terminal by executing "python"), or the python version specified under PYTHONHOME.
You are welcome to open this bash script with any editor and read it.
Related Question