I\'m trying to install Matlab Engine for Python
on CentOS 7 for Matlab R2016a using anaconda python 3.4.
I executed the following commands:
After so many tortures I finally solved this in a simple way. Instead of configure system to use anaconda's python by modifying .bash_profile, you can add an alternative to python command:
sudo update-alternatives --install /usr/bin/python python ~/anaconda3/envs/py34/bin/python 2
update-alternatives --display python
cd /usr/local/MATLAB/R2016a/extern/engines/python/
sudo python setup.py install
Just a reminder for those who have multiple virtual envs under the anacodna folder, after doing
python setup.py install --prefix="/Users/user/anaconda/"
as prompted by @Leighton, the matlab engine package is actually installed under the separate anacodna3/lib/python2.7/site-package/matlab folder rather than the normal anaconda3/lib/python3.7/site-package. So you need to manually move that matlab folder to the site-package folder your python is using. If you have multiple virtual envs, move it to the corresponding site-package folder of the virtual env you will run program.
cd "matlabroot\extern\engines\python"
python setup.py install --prefix="installdir"
For Unix (OSX10) python2.7, using Anaconda
cd /Applications/MATLAB_R2015a.app/extern/engines/python
python setup.py install --prefix="/Users/user/anaconda/"
Here is the Matlab Document:
https://www.mathworks.com/help/matlab/matlab_external/install-matlab-engine-api-for-python-in-nondefault-locations.html