My MATLAB 2022a not talking to Python 3.9.13

조회 수: 17 (최근 30일)
Ken Bannister
Ken Bannister 2022년 7월 26일
댓글: Ken Bannister 2022년 7월 28일
OK, the usual newby start-up problems. I downloaded Python 3.9.13 in hopes I could call Python routines from MATLAB. Not sure what else I have to do to so MATLAB can call (talk to) Python. The very first recommended step in the relevant MATLAB help documentation seems to be to issue the command "pyenv" in MATLAB. Here is the result I get:
=====================================================================================
>> pyenv
ans =
PythonEnvironment with properties:
Version: ""
Executable: ""
Library: ""
Home: ""
Status: NotLoaded
ExecutionMode: InProcess
=====================================================================================
Hmmm, not encouraging. Clearly, I need to do something else. But what? Is Python 3.9.13 not compatile with MATLAB 2022a?

채택된 답변

Mohammad Sami
Mohammad Sami 2022년 7월 26일
It seems that python is not your on paths list, hence its not auto detected by Matlab.
You can manually set the executable path using pyenv function so that Matlab can load python.
executable = 'C:\Users\xxxxxx\AppData\Local\Programs\Python\Python37\pythonw.exe';
pe = pyenv('Version',executable);
The variable executable specifies the full path to the Python executable. You can look for the path where you installed python.
  댓글 수: 2
Ken Bannister
Ken Bannister 2022년 7월 26일
OK Mohammad, many thanks, that seems to work! Here is what I get now after entering what you recommended (with a couple of minor changes you could not know about), and also what "pyenv" returns:
=============================================================================
>> executable = 'C:\Users\ken\AppData\Local\Programs\Python\Python39\pythonw';
pe = pyenv('Version',executable );
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "C:\Users\ken\AppData\Local\Programs\Python\Python39\pythonw.EXE"
Library: "C:\Users\ken\AppData\Local\Programs\Python\Python39\python39.dll"
Home: "C:\Users\ken\AppData\Local\Programs\Python\Python39"
Status: NotLoaded
ExecutionMode: InProcess
==================================================================================
Ken Bannister
Ken Bannister 2022년 7월 28일
Mohammad: I have done some trial runs with MATLAB calling Python and have gotten the expected results.
Many thanks once again!

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by