Anaconda install Matlab Engine on Linux
<p>I'm trying to install <code>Matlab Engine for Python</code> on CentOS 7 for Matlab R2016a using anaconda python 3.4.</p>

<p>I executed the following commands:</p>

<pre><code>source activate py34 # Default is python 3.5
python setup.py install
</code></pre>

<p>The output is:</p>

<pre><code>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 -&gt; /root/.local/lib/python2.7/site-packages/matlab/_internal
copying build/lib/matlab/_internal/__init__.py -&gt; /root/.local/lib/python2.7/site-packages/matlab/_internal
copying build/lib/matlab/_internal/mlarray_utils.py -&gt; /root/.local/lib/python2.7/site-packages/matlab/_internal
copying build/lib/matlab/mlarray.py -&gt; /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 -&gt; /root/.local/lib/python2.7/site-packages/matlab/engine
copying build/lib/matlab/engine/futureresult.py -&gt; /root/.local/lib/python2.7/site-packages/matlab/engine
copying build/lib/matlab/engine/fevalfuture.py -&gt; /root/.local/lib/python2.7/site-packages/matlab/engine
copying build/lib/matlab/engine/basefuture.py -&gt; /root/.local/lib/python2.7/site-packages/matlab/engine
copying build/lib/matlab/engine/matlabengine.py -&gt; /root/.local/lib/python2.7/site-packages/matlab/engine
copying build/lib/matlab/engine/__init__.py -&gt; /root/.local/lib/python2.7/site-packages/matlab/engine
copying build/lib/matlab/engine/enginesession.py -&gt; /root/.local/lib/python2.7/site-packages/matlab/engine
copying build/lib/matlab/engine/_arch.txt -&gt; /root/.local/lib/python2.7/site-packages/matlab/engine
copying build/lib/matlab/engine/matlabfuture.py -&gt; /root/.local/lib/python2.7/site-packages/matlab/engine
copying build/lib/matlab/mlexceptions.py -&gt; /root/.local/lib/python2.7/site-packages/matlab
copying build/lib/matlab/__init__.py -&gt; /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
</code></pre>

<p>It somehow install matlab engine into system's python version other than anaconda's <code>py34</code> virtual env. I noticed <a href="http://stackoverflow.com/questions/33357739/problems-installing-matlab-engine-for-python-with-anaconda">this</a> on OSX and it does work on my mac! Anyone can help with this on CentOS?</p>

<p>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:</p>

<pre><code>  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
</code></pre>

python matlab anaconda