Running matlab python interface in Jupyter Notebook throws weird error

4 ビュー (過去 30 日間)
Alexander Whatley
Alexander Whatley 2017 年 3 月 22 日
コメント済み: YL 2017 年 7 月 14 日
I'm trying to run the python matlab interface in the jupyter notebook. The simple import statement works in the terminal in the same directory as the notebook, but it does not work in the notebook itself. When I try
import matlab.engine
I get a long error message, which contains: ImportError: /home/alexander/anaconda3/lib/python3.5/site-packages/zmq/backend/cython/../../../../.././libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/local/MATLAB/R2017a/extern/engines/python/dist/matlab/engine/glnxa64/../../../../../../../bin/glnxa64/libmx.so)
I found this post, which said to set LD_LIBRARY_PATH to the location of libstdc++.so.6, which on my system is /usr/lib/x86_64-linux-gnu: http://stackoverflow.com/questions/36076395/import-of-matlab-engine-works-in-ipython-but-not-in-jupyter
I tried doing this, but I got the same error message. Any help is appreciated. Thanks.

採用された回答

Bo Li
Bo Li 2017 年 3 月 22 日
Probably the version of Jupyter uses an older version of GCC. You may consider forcing Jupyter to use MATLAB version of GCC runtime libraries, which are newer.
How is how I worked around it:
1. Back up the C runtime library and standard library from the library folder of anaconda, for example in "~/anaconda3/lib":
% mkdir backup
% mv libgcc_s* backup/
% mv libstdc++.so* backup/
2. Set up the LD_LIBRARY_PATH before launching Jupyter Notebook, for example with csh in "~/anaconda3/bin":
% setenv LD_LIBRARY_PATH /local/MATLAB/R2017a/sys/os/glnxa64/
% ./jupyter notebook
3. Create a Python notebook from the Jupyter Notebook browser and run following:
import matlab.engine
  1 件のコメント
YL
YL 2017 年 7 月 14 日
Thanks! I can now load matlab.engine on my own computer

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntegration with Online Platforms についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by