{"id":1598,"library":"oldest-supported-numpy","title":"Oldest Supported NumPy","description":"Oldest-supported-numpy is a meta-package that dynamically provides the oldest compatible NumPy version for a given Python interpreter and platform. It ensures that if a platform only gained support for NumPy wheels at a more recent version, that specific version is provided. The current version is 2023.12.21, and its release cadence is irregular, typically updated when new NumPy versions or platform support changes warrant it.","status":"active","version":"2023.12.21","language":"en","source_language":"en","source_url":"https://github.com/scipy/oldest-supported-numpy","tags":["numpy","meta-package","dependency-management","version-pinning","scipy-ecosystem"],"install":[{"cmd":"pip install oldest-supported-numpy","lang":"bash","label":"Install the meta-package"}],"dependencies":[],"imports":[],"quickstart":{"code":"import subprocess\nimport sys\n\n# Install oldest-supported-numpy, which in turn installs a specific numpy version\n# This example assumes pip is installed and available\n# In a real environment, you'd typically do 'pip install oldest-supported-numpy' once.\n# For this quickstart, we ensure numpy is uninstalled first to demonstrate the effect.\n\ntry:\n    # Uninstall numpy if present to ensure oldest-supported-numpy picks it up\n    subprocess.run([sys.executable, '-m', 'pip', 'uninstall', '-y', 'numpy'], check=True, capture_output=True)\nexcept subprocess.CalledProcessError as e:\n    # This is expected if numpy isn't installed initially\n    pass # print(f\"Uninstall failed (expected if not present): {e.stderr.decode().strip()}\")\n\n# Install oldest-supported-numpy, which will pull in a specific numpy version\nsubprocess.run([sys.executable, '-m', 'pip', 'install', 'oldest-supported-numpy'], check=True, capture_output=True)\n\n# Now, import numpy and check its version\nimport numpy as np\n\nprint(f\"NumPy version installed by oldest-supported-numpy: {np.__version__}\")\n\n# Basic NumPy usage\na = np.array([1, 2, 3])\nb = np.array([4, 5, 6])\nc = a + b\nprint(f\"Example NumPy array operation: {c}\")\n","lang":"python","description":"This quickstart demonstrates how to install `oldest-supported-numpy` and then verifies which NumPy version was installed by importing it and checking `np.__version__`. It then shows a basic NumPy operation."},"warnings":[{"fix":"Do not attempt to `import oldest_supported_numpy`. Instead, once installed, `import numpy` to use the NumPy library.","message":"The `oldest-supported-numpy` package itself does not have a Python API to import. Its sole purpose is to act as a dependency resolver, ensuring that a compatible (and often oldest-supported) version of the actual `numpy` package is installed into your environment.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always check `numpy.__version__` after installation to confirm the exact version. If you require a *specific* NumPy version that is newer than what `oldest-supported-numpy` provides, you must explicitly pin `numpy==X.Y.Z` in your `requirements.txt` or `pyproject.toml`.","message":"The *specific* NumPy version installed by `oldest-supported-numpy` is dynamic. It depends on your Python interpreter version (`sys.version_info`) and the platform/architecture you are running on (e.g., Linux, macOS, Windows, ARM, x86-64). It prioritizes the oldest *available wheel* for your specific environment, not necessarily the absolute oldest NumPy release.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For highly reproducible builds where the NumPy version must be identical across all environments, explicitly pin `numpy==X.Y.Z` in your dependency list. Use `oldest-supported-numpy` primarily when you need to ensure basic compatibility across a range of older Python versions without manually finding the minimal NumPy for each.","message":"Using `oldest-supported-numpy` can lead to non-deterministic NumPy versions across different environments if those environments use varying Python versions. For example, Python 3.8 might get NumPy 1.20, while Python 3.9 might get NumPy 1.22.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}