如何在 Apple Silicon (ARM/M1) 上安装 SciPy [英] How to install SciPy on Apple Silicon (ARM / M1)
问题描述
我已经在带有 Apple Silicon 的新 Mac mini 上成功安装了带有 Numpy 和 Matplotlib 的 python 3.9.1.但是,我无法安装 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 install scipy
python3 -m pip install scipy
我还尝试从 brew 安装所有内容,然后import 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
已经安装(从轮子),你需要卸载它:
If numpy
is already installed (from wheels) you'll need to uninstall it:
pip3 uninstall -y numpy pythran
我必须编译numpy
,这需要cython
和pybind11
:
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 需要 pythran
(这应该在安装 numpy 之后发生):
Scipy needs pythran
(this should happen after installing numpy):
pip3 install pythran
然后我们需要自己编译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屋!