我已经按照从Anaconda在Linux上将Matlab Engine安装到运行Python3.5的Anaconda虚拟环境的答案中的说明安装了官方的MATLAB Engine 。我现在可以导入matlab并且matlab.engine不会收到错误。但是,当我尝试:时 matlab.engine.start_matlab(),出现“分段错误(核心已转储)”
matlab
matlab.engine
matlab.engine.start_matlab()
我尝试从conda环境中设置LD_LIBRARY_PATH(以防万一,即使相关):,export LD_LIBRARY_PATH=/System/Library/Frameworks/Python.framework/Versions/Current/lib:$LD_LIBRARY_PATH但无济于事。据我所知,该路径也不存在,所以我也尝试过 export DYLD_LIBRARY_PATH=path_to_anaconda3/envs/myEnv/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/System/Library/Frameworks/Python.framework/Versions/Current/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=path_to_anaconda3/envs/myEnv/lib:$LD_LIBRARY_PATH
那么,如何在Anaconda虚拟环境中从Python启动matlab引擎/调用Matlab脚本?
顺便说一下,我在Ubuntu上
简短的答案:有两个问题需要解决
$LD_LIBRARY_PATH
长答案:将MATLAB Engine与Anaconda结合使用的完整安装说明
cd "/usr/local/MATLAB/R2017a/extern/engines/python"
sudo python3.5 setup.py install --prefix="/your_path_to_anaconda3/envs/your_env"
import matlab
find /your_path_to_anaconda3/envs/your_env/ -name libpython*
sudo ln -s /your_path_to_anaconda3/envs/your_env/lib/libpython3.5m.dylib /usr/lib
source activate your_env
echo $LD_LIBRARY_PATH
export LD_LIBRARY_PATH=only_paths_you_do_want_to_keep_separated_by_a_colon