Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

python - How to install SciPy on Apple Silicon (ARM / M1)

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

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

pip3 install cython pybind11

Then numpy can be compiled:

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

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

brew install openblas gfortran

Tell scipy where it can find this library:

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

Then finally compilescipy:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...