Matlab-python interface broken ?

31 ビュー (過去 30 日間)
Guillaume Leclerc
Guillaume Leclerc 2017 年 9 月 25 日
コメント済み: Pierre Loicq 2021 年 4 月 7 日
Hello,
I was experimenting with the Matlab-python interface and it seems there are serious issues.
Here are two very simple things I tried:
matrix = py.numpy.zeros(int32([3 3]))
py.scipy.linalg.det(matrix)
and it outputs 1. Actually it outputs 1 for any matrix
On the other side if I use
py.numpy.linalg.det(matrix)
I get a bunch of segmentation falt and illegal instruction errors.
When I do it with a python interpreter (in the same terminal I started Matlab to make sure i have the same environment) the code works properly.
Does anyone have the same behavior or is that my environment is somehow broken ?
Thank you for your help

回答 (1 件)

Robert Snoeberger
Robert Snoeberger 2017 年 9 月 27 日
When python is running within MATLAB, it ends up using MATLAB's MKL. It looks like your Python code is incompatible with MATLAB's MKL, probably due to incompatible compile-time options.
If you are on linux, then a workaround [1] to try is the following:
>> flag = int32(bitor(2, 8));
>> py.sys.setdlopenflags(flag);
Run this code after you start MATLAB.
  1. https://www.mathworks.com/matlabcentral/answers/265247-importing-custom-python-module-fails
  2 件のコメント
Guillaume Leclerc
Guillaume Leclerc 2017 年 9 月 28 日
This is AWESOME. Thank you for your help. Too bad I struggled days with the email support team for such a simple workaround.
Have a nice day
Pierre Loicq
Pierre Loicq 2021 年 4 月 7 日
Wow, this solution resolved a similar problem on matlab 2016b on linux (crash with segmentation faults and malloc errors).
Thank you very much

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

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by