Segmentation fault on import of scipy.integrate on Apple M1 ARM silicon
See original GitHub issueSciPy can be installed under native Python 3.9.1 on an Apple M1 system running macOS Big Sur 11.1 using these instructions. However, importing scipy.integrate gives a segmentation fault.
Reproducing code example:
$ brew install python@3.9
$ brew install openblas
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install cython --no-use-pep517
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install numpy --no-use-pep517
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install pandas --no-use-pep517
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install pybind11 --no-use-pep517
$ OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install scipy --no-use-pep517
$ python3
Python 3.9.1 (default, Dec 29 2020, 02:24:05)
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy.integrate
Error message:
I’m not sure how to install gdb on M1 – I’m not sure it’s possible yet. If there is another tool I can use to get a stack trace, please advise. Here is the detail on where in the import process the error occurs, via the last bit of verbose output achieved via python3 -vv:
...
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/quadpack.cpython-39-darwin.so
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/quadpack.abi3.so
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/quadpack.so
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/quadpack.py
# /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/__pycache__/quadpack.cpython-39.pyc matches /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/quadpack.py
# code object from '/opt/homebrew/lib/python3.9/site-packages/scipy/integrate/__pycache__/quadpack.cpython-39.pyc'
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/_quadpack.cpython-39-darwin.so
# extension module 'scipy.integrate._quadpack' loaded from '/opt/homebrew/lib/python3.9/site-packages/scipy/integrate/_quadpack.cpython-39-darwin.so'
# extension module 'scipy.integrate._quadpack' executed from '/opt/homebrew/lib/python3.9/site-packages/scipy/integrate/_quadpack.cpython-39-darwin.so'
import 'scipy.integrate._quadpack' # <_frozen_importlib_external.ExtensionFileLoader object at 0x116030880>
import 'scipy.integrate.quadpack' # <_frozen_importlib_external.SourceFileLoader object at 0x1151608e0>
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/_ode.cpython-39-darwin.so
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/_ode.abi3.so
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/_ode.so
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/_ode.py
# /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/__pycache__/_ode.cpython-39.pyc matches /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/_ode.py
# code object from '/opt/homebrew/lib/python3.9/site-packages/scipy/integrate/__pycache__/_ode.cpython-39.pyc'
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/vode.cpython-39-darwin.so
# extension module 'scipy.integrate.vode' loaded from '/opt/homebrew/lib/python3.9/site-packages/scipy/integrate/vode.cpython-39-darwin.so'
# extension module 'scipy.integrate.vode' executed from '/opt/homebrew/lib/python3.9/site-packages/scipy/integrate/vode.cpython-39-darwin.so'
import 'scipy.integrate.vode' # <_frozen_importlib_external.ExtensionFileLoader object at 0x116041580>
# trying /opt/homebrew/lib/python3.9/site-packages/scipy/integrate/_dop.cpython-39-darwin.so
zsh: segmentation fault /opt/homebrew/bin/python3 -vv -c "import scipy.integrate"
Scipy/Numpy/Python version information:
>> import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
1.6.0 1.19.5 sys.version_info(major=3, minor=9, micro=1, releaselevel='final', serial=0)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:22 (16 by maintainers)
Top Results From Across the Web
Segmentation fault for Apple Silicon M1 CPU #23 - GitHub
I attempted to replicate on my M1 MBP and didn't get a segmentation fault. $ git clone --branch testing_script https://github.com/frheault/ ...
Read more >How to install SciPy on Apple Silicon (ARM / M1)
This produces a segfault whenever I import a submodule of scipy. Numpy and matplotliib are fine, though. – David Sénéchal. Jan 17, 2021...
Read more >SciPy 1.7.3 Release Notes — SciPy v1.9.3 Manual
Issues closed for 1.7.3# ; #13364: Segmentation fault on import of scipy.integrate on Apple M1 ARM… ; #14688: BUG: ARPACK's eigsh & OpenBLAS...
Read more >Segmentation fault with scipy - ROOT Forum
The problem arises in a freshly compiled version of the SHiP software. I pinpoint the issue at the import of scipy.optimize.minimize function.
Read more >Napari, TensorFlow, AICSImageIO, StarDist, CARE/N2V ...
In a fresh apple-TF env, after using conda to get numba and scikit-image. The build succeeds, but then when I try to import...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I believe these were the same changes as made in
numpy-wheels: https://github.com/MacPython/scipy-wheels/pull/123There was one test in numpy that was marked as xfail which is the reason for the RuntimeWarnings here. https://github.com/numpy/numpy/issues/18555