如何在Apple Silicon(ARM/M1)上安装SciPy [英] How to install SciPy on Apple Silicon (ARM / M1)

查看:634
本文介绍了如何在Apple Silicon(ARM/M1)上安装SciPy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在装有Apple Silicon的新Mac mini上成功地将python 3.9.1,Numpy和Matplotlib安装在了Mac mini上.但是,我无法安装SciPy:使用时会出现编译错误

I have successfully installed python 3.9.1 with Numpy and Matplotlib on a new Mac mini with Apple Silicon. However, I cannot install SciPy : I get compilation errors when using

python3 -m pip安装scipy

python3 -m pip install scipy

我还尝试安装了brew中的所有内容,并导入scipy"可以,但是使用它会产生段错误.我已经安装了ARM版本的lapack和openblas,但这不能解决问题.

I also tried installing everything from brew, and "import scipy" works, but using it gives a seg fault. I have installed ARM versions of lapack and openblas, but this does not fix the problem.

有人成功吗?(我有兴趣在本地运行它,而不是通过Rosetta来运行.)

Has anyone succeeded? (I am interested in running it natively, not through Rosetta).

推荐答案

可以在常规的arm64 brew python上安装,您需要自己编译.

It's possible to install on regular arm64 brew python, you need to compile it yourself.

首先,我必须编译 numpy ,这需要 cython pybind11 :

First I had to compile numpy, which requires cython and pybind11:

pip3 install cython pybind11

然后可以编译 numpy :

pip3 install --no-binary :all: --no-use-pep517 numpy

然后我们需要编译scipy本身,这取决于fortran和BLAS/LACK:

Then we need to compile scipy itself, it depends on fortran and BLAS/LACK:

brew install openblas gfortran

告诉 scipy 在哪里可以找到此库:

Tell scipy where it can find this library:

export OPENBLAS=/opt/homebrew/opt/openblas/lib/

然后最终编译 scipy :

pip3 install --no-binary :all: --no-use-pep517 scipy

这篇关于如何在Apple Silicon(ARM/M1)上安装SciPy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆