简体   繁体   English

Matlab python 集成在 Apple Silicon 上

[英]Matlab python integration on Apple Silicon

I installed Python on my Apple M1 using miniforge我使用 miniforge 在我的 Apple M1 上安装了 Python

brew install --cask miniforge   

but I am not able to use a Conda environment on MATLAB:但我无法在 MATLAB 上使用 Conda 环境:

>> pyenv('Version', '/opt/homebrew/Caskroom/miniforge/base/envs/matpy39/bin/python3')

ans = 

  PythonEnvironment with properties:

          Version: "3.9"
       Executable: "/opt/homebrew/Caskroom/miniforge/base/envs/matpy39/bin/python3"
          Library: "/opt/homebrew/Caskroom/miniforge/base/envs/matpy39/lib/libpython3.9.dylib"
             Home: "/opt/homebrew/Caskroom/miniforge/base/envs/matpy39"
           Status: NotLoaded
    ExecutionMode: InProcess

>> py.list({1})
Unable to resolve the name py.list.

However, if I use Macs built in python version, it does work:但是,如果我使用内置 python 版本的 Mac,它确实有效:

>> pyversion('/usr/bin/python3')
>> py.list({1})

ans = 

  Python list with no properties.

    [1.0]

I am not sure what to do so that MATLAB uses a specific Conda environment我不确定该怎么做,以便 MATLAB 使用特定的 Conda 环境

Homebrew builds native ARM/M1 binaries on Apple Silicon now. Homebrew 现在在 Apple Silicon 上构建原生 ARM/M1 二进制文件。 Matlab is an x64 binary running under Rosetta emulation. Matlab 是在 Rosetta 仿真下运行的 x64 二进制文件。 I suspect the problem is that you can't load an ARM library (Homebrewed Python) into an x64/Rosetta process (Matlab).我怀疑问题是您无法将 ARM 库(自制 Python)加载到 x64/Rosetta 进程(Matlab)中。 I bet macOS's system Python distribution is a "universal" build or similar thing that can load in to either kind of process.我敢打赌 macOS 的系统 Python 发行版是一个“通用”构建或类似的东西,可以加载到任何一种进程中。

You can probably get this to work by installing an x64 version of Anaconda outside Homebrew, and telling Matlab to load that.您可以通过在 Homebrew 外部安装 x64 版本的 Anaconda 并告诉 Matlab 加载它来实现此功能。

Have a look at https://www.anaconda.com/blog/apple-silicon-transition .看看https://www.anaconda.com/blog/apple-silicon-transition

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM