{"id":330,"library":"scipy","title":"SciPy","description":"SciPy is a Python library for scientific computing, offering modules for optimization, integration, interpolation, linear algebra, statistics, and more. The current version is 1.17.1, released on February 22, 2026, with a regular release cadence of approximately every 6 months.","status":"active","version":"1.17.1","language":"python","source_language":"en","source_url":"https://github.com/scipy/scipy","tags":["scientific computing","Python","numerical methods","open source"],"install":[{"cmd":"pip install scipy","lang":"bash","label":"Install SciPy"}],"dependencies":[{"reason":"SciPy depends on NumPy for array operations and numerical computations.","package":"numpy"}],"imports":[{"note":"Ensure correct submodule import for shortest_path function.","symbol":"shortest_path","correct":"from scipy.sparse.csgraph import shortest_path"},{"note":"Ensure correct submodule import for geometric_slerp function.","symbol":"geometric_slerp","correct":"from scipy.spatial import geometric_slerp"}],"quickstart":{"code":"import numpy as np\nfrom scipy.sparse.csgraph import shortest_path\n\n# Create a sample graph as a 2D NumPy array\ngraph = np.array([[0, 1, 2], [1, 0, 0], [2, 0, 0]])\n\n# Compute the shortest path distances\ndist_matrix, predecessors = shortest_path(graph, return_predecessors=True)\n\nprint('Shortest path distance matrix:')\nprint(dist_matrix)","lang":"python","description":"This example demonstrates how to compute the shortest path distances in a graph using SciPy's sparse graph module."},"warnings":[{"fix":"Upgrade your Python installation to version 3.11 or later.","message":"SciPy 1.17.1 requires Python 3.11 or higher.","severity":"breaking","affected_versions":"1.17.1"},{"fix":"Install NumPy first using 'pip install numpy'.","message":"Ensure that NumPy is installed before SciPy, as SciPy depends on NumPy for array operations.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T13:06:59.446Z","next_check":"2026-09-28T00:00:00.000Z","problems":[{"fix":"Ensure 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.","cause":"SciPy's installation from source (which pip attempts if no pre-built wheel is available) requires a C/Fortran compiler toolchain on your system.","error":"Failed building wheel for scipy"},{"fix":"Provide better initial guesses for the parameters (`p0`), increase the maximum number of iterations (`maxfev`), or add bounds to the parameters (`bounds`).","cause":"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.","error":"Optimal parameters not found: The iteration is not making good progress, as measured by the improvement from the last ten iterations."},{"fix":"Import `interp1d` from its correct submodule: `from scipy.interpolate import interp1d`.","cause":"The `interp1d` function is part of the `scipy.interpolate` submodule, but the code attempted to access it directly from the top-level `scipy` module.","error":"AttributeError: module 'scipy' has no attribute 'interp1d'"},{"fix":"Check 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.","cause":"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.","error":"scipy.linalg.LinAlgError: Singular matrix"},{"fix":"Examine 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`).","cause":"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.","error":"IntegrationWarning: The integral is probably divergent, or slowly convergent."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.91,"mem_mb":22.6,"disk_size":"230.6M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.66,"mem_mb":22.6,"disk_size":"222M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.38,"mem_mb":25.2,"disk_size":"245.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.14,"mem_mb":25.2,"disk_size":"235M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.25,"mem_mb":25,"disk_size":"231.8M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.31,"mem_mb":25,"disk_size":"221M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.05,"mem_mb":24.4,"disk_size":"230.5M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.14,"mem_mb":24.4,"disk_size":"220M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.65,"mem_mb":16.3,"disk_size":"232.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.63,"mem_mb":16.3,"disk_size":"229M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}