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

8 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Rubem Pacelli
Rubem Pacelli el 18 de Mzo. de 2020
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 comentario
Pierre Loicq
Pierre Loicq el 7 de Abr. de 2021
I resolved the exact same problem on Matlab 2016b with this one : https://fr.mathworks.com/matlabcentral/answers/358233-matlab-python-interface-broken

Iniciar sesión para comentar.

Más respuestas (3)

Hiro Yoshino
Hiro Yoshino el 4 de Feb. de 2020
  6 comentarios
Rubem Pacelli
Rubem Pacelli el 5 de Feb. de 2020
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 :(

Iniciar sesión para comentar.


Hiro Yoshino
Hiro Yoshino el 5 de Feb. de 2020
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

Hiro Yoshino
Hiro Yoshino el 6 de Feb. de 2020
Have you ever tried this ? - calling MATLAB from the anaconda prompt?

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by