MATLAB: How to uninstall the MATLAB Engine API for Python

engineMATLABpython

I have MATLAB R2016a and I would like to interface it with Python. I have Python 3.6 and I installed the MATLAB Engine API for Python. However, I receive the following error:
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance: No module named 'matlabengineforpython3_6'
From the system requirements, I saw that the latest Python version supported by MATLAB R2016a is the 3.4. Therefore, I think that the easiest way to solve this issue is to upgrade MATLAB to MATLAB R2018a, which supports Python 3.6.
However, I would like to know if I need to uninstall the MATLAB Engine API for Python that I already installed or if I can just install the new API.
If I need to uninstall the previous API, can you guide me through the process?

Best Answer

There is no need for uninstalling the MATLAB Engine previously installed for a different MATLAB release. In fact, if you install the latest release of MATLAB, which is R2018a, you can reinstall the MATLAB Engine API for Python following the instructions below from the MATLAB Documentation:
or
After you installed the latest MATLAB Engine API for Python, please close your Python instances and open it again.
You can now import the MATLAB engine and start it through the following commands:
>>> import matlab.engine
>>> eng = matlab.engine.start_matlab()
If you open the Windows Task Manager, you will see that the MATLAB version called by Python is the latest one.
Please note that the same workflow works fine also if you want to install the MATLAB Engine related to a previous MATLAB release.