Why matlab crashes when I try to use a numpy Python package? (2019a)

12 ビュー (過去 30 日間)
Rubem Pacelli
Rubem Pacelli 2020 年 2 月 4 日
コメント済み: Pierre Loicq 2021 年 4 月 7 日
I'm trying to use Python on Matlab, but the system crashes everytime I try to use a Numpy Package.
My only step was to switch the pyversion to match with anaconda executable version (I'm on Linux):
pyversion
version: '3.7'
executable: '/home/rubem/anaconda3/bin/python'
library: '/home/rubem/anaconda3/lib/libpython3.7m.so'
home: '/home/rubem/anaconda3'
isloaded: 0
If a type something like:
py.importlib.import_module('numpy')
or:
py.numpy.limspace(0,10,101)
Matlab crashes. In the Terminal, the following command appear:
malloc(): memory corruption
/usr/local/bin/matlab: line 3: 1874 Segmentation fault sudo /usr/local/Polyspace/R2019a/bin/matlab
Despite the lack of documentation on Matlab, I tried to find out what the hell was going on and I found out two interesting things:
1 - I followed the example in https://www.mathworks.com/help/matlab/matlab_external/call-user-defined-custom-module.html and it's works. So I Think that just the numpy package has the problem
2 - If I type
py.sys.path
I recieve:
ans =
Python list with no properties.
['', '/home/rubem/anaconda3/lib/python37.zip', '/home/rubem/anaconda3/lib/python3.7', '/home/rubem/anaconda3/lib/python3.7/lib-dynload', '/home/rubem/anaconda3/lib/python3.7/site-packages']
That's weird because the second one isn't a path folder (python37 is a .zip-file that doesn't exist). Unfortunately, I don't know how I can change this.
3 - "isloaded" is equal to zero when the matlab initialize. I don't know neither how I set this logical variable nor what is this does (I swear for god I searched, but the documentation on Matlab is very poor yet).
How can I solve this problem?

採用された回答

Rubem Pacelli
Rubem Pacelli 2020 年 3 月 18 日
I think the problem was my program. I switched to 2018b and it seems to work.
btw, I think its more useful to close this post because the problem wasn't technical questions.
  1 件のコメント
Pierre Loicq
Pierre Loicq 2021 年 4 月 7 日
I resolved the exact same problem on Matlab 2016b with this one : https://fr.mathworks.com/matlabcentral/answers/358233-matlab-python-interface-broken

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

その他の回答 (3 件)

Hiro Yoshino
Hiro Yoshino 2020 年 2 月 4 日
  6 件のコメント
Hiro Yoshino
Hiro Yoshino 2020 年 2 月 5 日
Rubem Pacelli
Rubem Pacelli 2020 年 2 月 5 日
Hiro Yoshino, i saw all yours links.
1 - The command "pyenv" seems don't exist on 2019a.
Undefined function or variable 'pyenv'
2 - According to what I read: "MATLAB automatically selects and loads a Python version when you type a Python command, such as: py.funcname" . I did it. I created a silly .py-function called "my_python_function.py" and I call it from matlab. It's work because I don't use numpy package. Then, I typed pyversion and I recieve:
version: '3.7'
executable: '/home/rubem/anaconda3/bin/python'
library: '/home/rubem/anaconda3/lib/libpython3.7m.so'
home: '/home/rubem/anaconda3'
isloaded: 1
however, If I type then
py.importlib.import_module('numpy')
My matlab crashes anyway :(

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


Hiro Yoshino
Hiro Yoshino 2020 年 2 月 5 日
Read the documentation for R2019a. You might have counted on the latest. It might be a cause of the problem.
Sometimes, there exists slight difference across the versions.
https://jp.mathworks.com/help/releases/R2019a/index_ja_JP.html
  1 件のコメント
Rubem Pacelli
Rubem Pacelli 2020 年 2 月 5 日
Hiro Yoshino, I read this. Unfortunately, nothing there help to solve my problem

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


Hiro Yoshino
Hiro Yoshino 2020 年 2 月 6 日
Have you ever tried this ? - calling MATLAB from the anaconda prompt?

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by