필터 지우기
필터 지우기

Cannot access Python using PythonEnvironment

조회 수: 10 (최근 30일)
Ben Dichter
Ben Dichter 2023년 5월 17일
댓글: Masanori Hariyama 2023년 6월 17일
I am unable to get a PythonEnvironment to work
>> pyenv('Version', '/Users/bendichter/opt/miniconda3/bin/python')
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "/Users/bendichter/opt/miniconda3/bin/python"
Library: "/Users/bendichter/opt/miniconda3/lib/libpython3.9.dylib"
Home: "/Users/bendichter/opt/miniconda3"
Status: NotLoaded
ExecutionMode: InProcess
>> py.math.sqrt(42)
Unable to resolve the name 'py.math.sqrt'.
>> py.list({'a','b'});
Unable to resolve the name 'py.list'.
I have tried a few different versions of Python in various conda environments. I am using coda and an M1 mac. The print out of pyenv seems to indicate that the python installation is registered correctly, but none of the subsequent commands that use the Python connection work.
  댓글 수: 1
Masanori Hariyama
Masanori Hariyama 2023년 6월 17일
Hi, I had the same problem, and fixed it.
For M1 mac, we can install intel and arm versions of python.
When I installed the arm version, the problem occured. When I installed the Intel version, the problem did not occurred.
I hope this can be helpful for you.

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

답변 (1개)

Himanshu
Himanshu 2023년 5월 22일
Hello Ben,
I understand that you are facing difficulties while using the MATLAB Python co-execution feature and encountering errors while executing the Python commands.
You can follow the below steps to resolve the issue:
  1. MATLAB automatically loads Python when you type "py.command". You cannot change the interpreter after MATLAB loads Python. To change the interpreter, restart MATLAB.
  2. After restarting, check that MATLAB is using the desired Python environment. You can do this by running the "pyenv" command in MATLAB.
You can refer to the below documentation to understand more about "pyenv" in MATLAB.

카테고리

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

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by