且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Apple Silicon (ARM/M1) 上安装 SciPy

更新时间:2022-01-26 22:02:57

普通的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,这需要cythonpybind11:

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