Not able to access Python from MATLAB on Apple silicon

6 ビュー (過去 30 日間)
Somnath Mukherjee
Somnath Mukherjee 2024 年 3 月 23 日
コメント済み: Somnath Mukherjee 2024 年 4 月 26 日
I referred this page https://in.mathworks.com/matlabcentral/answers/1977529-how-to-use-python-from-matlab-on-mac-with-apple-silicon?s_tid=mwa_osa_a, and executed the command "arch -x86_64 python3 -m pip myPythonPackage" from my python virtual environment, and thought that it would resolve my problem of not able to access "py.sys.path", but it didn't help. I get the following error:
Python commands require a supported version of CPython. See Getting Started with Python.
My Python environement is given as below when printed from within MATLAB:
PythonEnvironment with properties:
Version: "3.9"
Executable: "/Users/<user-name>/venv/bin/python"
Library: "/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib"
Home: "/Users/<user-name>/venv"
Status: NotLoaded
ExecutionMode: InProcess
Note that executing "arch -x86_64 python3 -m pip myPythonPackage" resulted the following error:
arch: posix_spawnp: python3: Bad CPU type in executable
My MATLAB verison is 2021b on Apple M1 Pro
Any help will be highly appreciated.
  1 件のコメント
Somnath Mukherjee
Somnath Mukherjee 2024 年 4 月 19 日
移動済み: Walter Roberson 2024 年 4 月 19 日
Hi,
Can someone please respond to this query?
Regards,
Somnath

サインインしてコメントする。

回答 (1 件)

Karanjot
Karanjot 2024 年 3 月 23 日
Hi Somnath,
Do you have the Rosetta 2 translation layer for Apple Silicon macs installed?
If you haven't been prompted for any other app already, manually install Rosetta 2:
softwareupdate --install-rosetta
Adittionally, If this doesn't resolve your issue, I recommend running the following command & inspecting the results.
which -a python
Multiple python installations could be causing this error as well, if the wrong one is being invoked.
Do note that only certain python versions are supported for MATLAB R2021b. You may check the supported versions at the webpage below:
  3 件のコメント
Karanjot
Karanjot 2024 年 4 月 25 日
編集済み: Karanjot 2024 年 4 月 25 日
Hi,
This seems to be an issue with Rosetta / Apple. Although, Rosetta installation was completed sucessfully as the next line suggests that.
Somnath Mukherjee
Somnath Mukherjee 2024 年 4 月 26 日
Ok. So, do you have any further recoomendations on what should be done next?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by