Why matlab crashes when I try to use a numpy Python package? (2019a)
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (3)
Hiro Yoshino
le 4 Fév 2020
0 votes
This might be useful:
6 commentaires
Rubem Pacelli
le 4 Fév 2020
Hiro Yoshino
le 4 Fév 2020
How about updating your MATLAB?
Rubem Pacelli
le 5 Fév 2020
Hiro Yoshino
le 5 Fév 2020
Look like your Python has not been properly loaded in the first place.

isloaded is supposed to be 1 if it is loaded:
You should re-set it up again by following:
Hiro Yoshino
le 5 Fév 2020
This might be helpful:
Rubem Pacelli
le 5 Fév 2020
Hiro Yoshino
le 5 Fév 2020
0 votes
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 commentaire
Rubem Pacelli
le 5 Fév 2020
Hiro Yoshino
le 6 Fév 2020
0 votes
Have you ever tried this ? - calling MATLAB from the anaconda prompt?
Catégories
En savoir plus sur Call Python from MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!