Install & Compatibility
Where this runs
tested against v1.15.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.040s · 230.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 7.4s · import 0.996s · 222MB
230MB installed
● package 230MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
shortest_path
✓ from scipy.sparse.csgraph import shortest_path
Ensure correct submodule import for shortest_path function.
geometric_slerp
✓ from scipy.spatial import geometric_slerp
Ensure correct submodule import for geometric_slerp function.
This example demonstrates how to compute the shortest path distances in a graph using SciPy's sparse graph module.
import numpy as np
from scipy.sparse.csgraph import shortest_path
# Create a sample graph as a 2D NumPy array
graph = np.array([[0, 1, 2], [1, 0, 0], [2, 0, 0]])
# Compute the shortest path distances
dist_matrix, predecessors = shortest_path(graph, return_predecessors=True)
print('Shortest path distance matrix:')
print(dist_matrix)
Errors
Common errors & fixes
Failed building wheel for scipy
SciPy's installation from source (which pip attempts if no pre-built wheel is available) requires a C/Fortran compiler toolchain on your system.
fixEnsure you have `numpy` pre-installed and use a compatible Python version for which pre-built wheels exist, or install the necessary compiler tools (e.g., build-essential on Linux, Xcode Command Line Tools on macOS, Visual C++ build tools on Windows). Often, `pip install --upgrade pip` followed by `pip install numpy scipy` resolves it.
Optimal parameters not found: The iteration is not making good progress, as measured by the improvement from the last ten iterations.
The `scipy.optimize.curve_fit` algorithm failed to converge to a stable solution, often due to poor initial guesses, ill-conditioned data, or an unsuitable model function.
fixProvide better initial guesses for the parameters (`p0`), increase the maximum number of iterations (`maxfev`), or add bounds to the parameters (`bounds`).
AttributeError: module 'scipy' has no attribute 'interp1d'
The `interp1d` function is part of the `scipy.interpolate` submodule, but the code attempted to access it directly from the top-level `scipy` module.
fixImport `interp1d` from its correct submodule: `from scipy.interpolate import interp1d`.
scipy.linalg.LinAlgError: Singular matrix
This error occurs when a linear algebra operation (like matrix inversion) is performed on a singular matrix, which has a determinant of zero and thus no unique inverse.
fixCheck the input matrix for linear dependencies or near-singularities. If solving a system, consider using a pseudo-inverse (`numpy.linalg.pinv` or `scipy.linalg.pinv`) or least squares (`numpy.linalg.lstsq`) instead of direct inversion.
IntegrationWarning: The integral is probably divergent, or slowly convergent.
The `scipy.integrate.quad` function struggled to evaluate the integral, often indicating a singularity, discontinuity, or highly oscillatory behavior of the integrand within the integration range.
fixExamine the integrand for singularities or problematic points within the integration interval. If known, specify singular points using the `points` argument in `quad`, split the integral, or adjust error tolerances (`epsabs`, `epsrel`).
Upgrade
Version history
1.18.1latest on PyPI · released Aug 21, 2026
Audit
Dependencies
numpyrequiredSciPy depends on NumPy for array operations and numerical computations.