Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Matlab engine in Anaconda Python (Linux)

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:

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

The output is:

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 install matlab engine into system's python version other than anaconda's py34 virtual env. I noticed this on OSX and it does work on my mac! Anyone can help with this on CentOS?

like image 929
spacegoing Avatar asked Sep 25 '16 16:09

spacegoing


People also ask

Can I use MATLAB in Anaconda?

Currently, MATLAB isn't supported for Anaconda environment.

How do I add MATLAB to Python?

Install Using pip Starting with MATLAB R2022b, you can use the pip command to install the API. Choose one of the following procedures and execute from the system prompt. To install from the MATLAB folder, on Windows® type: cd "matlabroot\extern\engines\python" python -m pip install .


1 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 Document:

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

like image 163
Leighton Avatar answered Nov 03 '22 01:11

Leighton