在 Anaconda Python (Linux) 中安装 Matlab 引擎

2022-01-10 00:00:00 python anaconda matlab

问题描述

我正在尝试使用 anaconda python 3.4 在 CentOS 7 上为 Matlab R2016a 安装 Matlab Engine for Python.

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

我执行了以下命令:

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

输出是:

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

它以某种方式将 matlab 引擎安装到系统的 python 版本中,而不是 anaconda 的 py34 虚拟环境.我在 OSX 上注意到 this 并且它在我的 Mac 上工作!任何人都可以在 CentOS 上提供帮助吗?

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?


解决方案

cd "matlabrootexternenginespython"
python setup.py install --prefix="installdir"

对于 Unix (OSX10) python2.7,使用 Anaconda

For Unix (OSX10) python2.7, using Anaconda

cd /Applications/MATLAB_R2015a.app/extern/engines/python
python setup.py install --prefix="/Users/user/anaconda/"

这是 Matlab 文档:

Here is the Matlab Document:

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

相关文章