Trouble importing Python Modules in MATLAB
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
While I can run simple scripts, I cannot run scripts that import modules such as numpy or pathlib. While I realize this question has been asked many times before, I can't seem to find any of the files or succesfully change the MATLAB search path.
When running a scipt the error I get is:
ModuleNotFoundError: No module named 'numpy'
When attempting to use py.anything I get:
Unable to resolve the name py.importlib.import_module.
When I type pyversion nothing happens
I have Anaconda3 downloaded as well as CPython 64-bit. MATLAB version 2019b for reference.
I understand I have to fix the search path but when I add the path (or attempt to) nothing happens and I continue to get the same errors. Also I realize most of these issues are addressed in the documentation, but as someone not familiar with this software it is a little too tricky for me to figure out.
1 comentario
Shrinidhi KR
el 8 de Mayo de 2020
It is recommended to use pyenv instead of pyversion in R2019b version
Respuestas (1)
Harsha Priya Daggubati
el 16 de Mzo. de 2020
Editada: Harsha Priya Daggubati
el 16 de Mzo. de 2020
Hi,
MATLAB does not support Anaconda Python. To call Python libraries from MATLAB, you need to install a supported version of the reference implementation (CPython) for Python. MATLAB supports versions 2.7, 3.5, and 3.6. You can download CPython from https://www.python.org/downloads/
You can also refer to the following threads in which relatable questions are asked:
I think this approach answers your query: https://www.mathworks.com/matlabcentral/answers/410406-import-numpy-to-matlab?s_tid=answers_rc1-3_p3_Topic
Hope this helps!
1 comentario
Akshay Jajoo
el 9 de Sept. de 2021
@Harsha Priya Daggubati , Support for Matlab 2020A and 2020B is still the same 2.7, 3.5 and 3.6? Where can I find the information about the latest supported versions?
Also, when you say 3.6. Does it mean exactly 3.6 or any 3.6.x will work?
Ver también
Categorías
Más información sobre Call Python from MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!