Trouble importing Python Modules in MATLAB

조회 수: 6 (최근 30일)
Alex Weaver
Alex Weaver 2020년 3월 12일
댓글: Akshay Jajoo 2021년 9월 9일
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개)

Harsha Priya Daggubati
Harsha Priya Daggubati 2020년 3월 16일
편집: Harsha Priya Daggubati 2020년 3월 16일
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:
Hope this helps!
  댓글 수: 1
Akshay Jajoo
Akshay Jajoo 2021년 9월 9일
@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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by