Segmentation fault (core dumped)
ID: python/segfault-numpy-import
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 311 | active | — | — | — |
Root Cause
The segfault is caused by numpy's bundled OpenBLAS failing to detect the correct ARM CPU core type at runtime. Setting the OPENBLAS_CORETYPE environment variable or switching to conda-forge's numpy (which ships with a properly configured OpenBLAS for ARM) resolves the issue in most cases.
genericWorkarounds
-
84% success Set OPENBLAS_CORETYPE environment variable before import
Export OPENBLAS_CORETYPE=ARMV8 (or CORTEXA72, CORTEXA53, etc. depending on your CPU) before running Python. Add to shell profile: 'export OPENBLAS_CORETYPE=ARMV8'. This overrides the faulty auto-detection and forces OpenBLAS to use a safe, compatible code path.
Sources: https://github.com/OpenMathLib/OpenBLAS/wiki/Faq#what-is-openblas_coretype
-
89% success Install numpy via conda-forge
Use 'conda install -c conda-forge numpy' or 'mamba install -c conda-forge numpy'. Conda-forge builds numpy with OpenBLAS configured specifically for the target architecture and includes proper ARM detection.
Sources: https://conda-forge.org/
-
71% success Build numpy from source with system BLAS
Install system OpenBLAS ('apt install libopenblas-dev') then 'pip install numpy --no-binary numpy'. This compiles numpy against the system's properly configured BLAS rather than the bundled one.
Dead Ends
Common approaches that don't work:
-
Reinstalling numpy with 'pip install --force-reinstall numpy'
93% fail
The crash is not caused by a corrupt installation. It is caused by the OpenBLAS library bundled inside the numpy wheel failing to auto-detect the ARM CPU microarchitecture. Reinstalling downloads the same binary wheel with the same broken auto-detection.
-
Upgrading pip and setuptools
97% fail
The segfault occurs inside numpy's compiled C/Fortran code (OpenBLAS), which has no dependency on pip or setuptools at runtime. Upgrading build tools has zero effect on the runtime behavior of already-compiled shared objects.
-
Downgrading numpy to an older version
72% fail
Older numpy versions have the same or worse ARM support. The OpenBLAS auto-detection issue has been present across multiple numpy versions. Older versions are more likely to lack arm64 wheel support entirely, forcing a slow source build that may also fail.