Installing SciPy and the subpackage map
Install SciPy so it matches your NumPy, then learn which of the fifteen subpackages solves which kind of numerical problem.
Installation and version pairing
python -m venv .venv && source .venv/bin/activate
# the usual route: wheels that already bundle the compiled libraries
pip install numpy scipy
# from a fully specified environment
pip install -r requirements.txt
python -c "import scipy, numpy; print(scipy.__version__, numpy.__version__)"SciPy is mostly compiled code. Install it from a binary wheel wherever possible; building from source needs a Fortran compiler, OpenBLAS and a lot of patience, and is rarely necessary outside platform packaging.
- SciPy declares a required NumPy range. Mixing a much newer NumPy with an older SciPy produces
ValueErrororImportErrorabout ABI version at import time. - Do not overwrite a system or conda environment with
pip install --user; create a dedicated environment per project. - On ARM machines, check
scipy.show_config()to confirm which BLAS backend you actually linked against.
The subpackage map
| Subpackage | Solves | Typical call |
|---|---|---|
scipy.linalg | Dense linear algebra: factorisations, solvers, eigenvalues | solve, lu, eigh |
scipy.sparse | Matrices that are mostly zeros | csr_matrix, spsolve |
scipy.optimize | Minimisation, root finding, curve fitting | minimize, brentq, curve_fit |
scipy.integrate | Quadrature and ODE solvers | quad, solve_ivp |
scipy.interpolate | Filling in between known points | CubicSpline, RBFInterpolator |
scipy.stats | Distributions, tests, descriptive statistics | norm.fit, ttest_ind |
scipy.signal | Filter design and application, peak detection | butter, find_peaks |
scipy.fft | Fast Fourier transforms | rfft, spectrogram |
scipy.ndimage | N-dimensional image operations | gaussian_filter, label |
scipy.spatial | Nearest neighbours, geometry, distance | cKDTree, Delaunay |
scipy.special | Special mathematical functions | gammaln, erfc, comb |
Import subpackages explicitly (from scipy import linalg) rather than relying on import scipy. The top-level namespace is deliberately thin, so attribute access there is a common source of AttributeError.
💡
Work out which subpackage owns your problem before you start coding. Half of the answers on a search engine use the wrong tool simply because the solver looked close enough, and you only notice when the numbers are subtly wrong.
FAQ
Do I need SciPy if I already have NumPy?
Only for problems NumPy does not cover well: sparse matrices, ODE solvers, quadrature, statistical tests, signal processing, image morphology, spatial indexes. Everything SciPy returns is a NumPy array, so the two work together rather than in competition.
Why does import fail with a NumPy ABI error?
The installed SciPy was compiled against a different NumPy major version. Upgrade both together with
pip install --upgrade numpy scipy, or pin a known-good pair in your requirements file.Related
SciPy arrays and NumPy interop Linear algebra with scipy.linalg
Last refreshed 2026-09-18.