Anaconda installs Matlab Engine on Linux

I am trying to install Matlab Engine for Python on CentOS 7 for Matlab R2016a using anaconda python 3.4.

I executed the following commands:

 source activate py34 # Default is python 3.5 python setup.py install 

Output:

 running install running build running build_py running install_lib creating /root/.local/lib/python2.7/site-packages/matlab creating /root/.local/lib/python2.7/site-packages/matlab/_internal copying build/lib/matlab/_internal/mlarray_sequence.py -> /root/.local/lib/python2.7/site-packages/matlab/_internal copying build/lib/matlab/_internal/__init__.py -> /root/.local/lib/python2.7/site-packages/matlab/_internal copying build/lib/matlab/_internal/mlarray_utils.py -> /root/.local/lib/python2.7/site-packages/matlab/_internal copying build/lib/matlab/mlarray.py -> /root/.local/lib/python2.7/site-packages/matlab creating /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/engine/engineerror.py -> /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/engine/futureresult.py -> /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/engine/fevalfuture.py -> /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/engine/basefuture.py -> /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/engine/matlabengine.py -> /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/engine/__init__.py -> /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/engine/enginesession.py -> /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/engine/_arch.txt -> /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/engine/matlabfuture.py -> /root/.local/lib/python2.7/site-packages/matlab/engine copying build/lib/matlab/mlexceptions.py -> /root/.local/lib/python2.7/site-packages/matlab copying build/lib/matlab/__init__.py -> /root/.local/lib/python2.7/site-packages/matlab byte-compiling /root/.local/lib/python2.7/site-packages/matlab/_internal/mlarray_sequence.py to mlarray_sequence.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/_internal/__init__.py to __init__.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/_internal/mlarray_utils.py to mlarray_utils.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/mlarray.py to mlarray.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/engine/engineerror.py to engineerror.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/engine/futureresult.py to futureresult.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/engine/fevalfuture.py to fevalfuture.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/engine/basefuture.py to basefuture.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/engine/matlabengine.py to matlabengine.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/engine/__init__.py to __init__.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/engine/enginesession.py to enginesession.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/engine/matlabfuture.py to matlabfuture.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/mlexceptions.py to mlexceptions.pyc byte-compiling /root/.local/lib/python2.7/site-packages/matlab/__init__.py to __init__.pyc running install_egg_info Writing /root/.local/lib/python2.7/site-packages/matlabengineforpython-R2016a-py2.7.egg-info 

It somehow installs the matlab mechanism into a python system version other than anaconda py34 virtual env. I noticed this one on OSX and it works on my Mac! Can anyone help with this on CentOS?

+4
source share
3 answers
 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 doc:

https://www.mathworks.com/help/matlab/matlab_external/install-matlab-engine-api-for-python-in-nondefault-locations.html

+6
source

After so many tortures, I finally solved it in a simple way. Instead of setting up the system to use anaconda python by modifying the .bash_profile file, you can add an alternative to the 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 
+3
source

Just a reminder for those who have several virtual envs in the anacodna folder, after running python setup.py install --prefix="/Users/user/anaconda/" as @Leighton suggests, the matlab engine package is actually installed under a separate anacodna3 / folder lib / python2.7 / site-package / matlab, not the regular folder anaconda3 / lib / python3.7 / site-package. Therefore, you need to manually move this matlab folder to the site-package folder that your python uses. If you have several virtual envs, move them to the appropriate site-package folder of the virtual env in which you will run the program.

0
source

All Articles