NumPy Installation and Versions
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
NumPy is the array library that almost all of the scientific Python stack is built on, so getting the installation right is the first step of every data science project. This page covers how to install NumPy, how to check what you have, how NumPy is versioned and released, and what changed between NumPy 2.0 and 2.5 so that older code, books and tutorials can be read critically. It targets NumPy 2.5 (the 2.5.4 patch release, published in October 2026), and every statement was checked in October 2026. Examples target Python 3.13 or 3.14 and were run on Python 3.13. All the examples were executed with NumPy 2.5.4.
For the general mechanics of virtual environments, pip and lock files see Virtual Environments and Packaging and Lock Files and Reproducible Installs. For the data science specific choices (venv or uv or Miniforge, binary wheels, BLAS threads, version policy of the scientific projects) see Setting Up a Data Science Environment. This page does not repeat them.
Installing NumPy
NumPy publishes binary wheels for the mainstream platforms, so a normal installation needs no compiler. Install it into an isolated environment rather than into the system Python.
With pip in a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install numpy
python -c "import numpy as np; print(np.__version__)"
Source: NumPy installation instructions.
Use python -m pip rather than a bare pip, so that the package is installed for the interpreter that you are going to
run. Pin the version when reproducibility matters, for example python -m pip install "numpy>=2.5,<2.6", and record the
whole environment in a lock file (see the lock file page linked above).
With uv
uv init analysis && cd analysis
uv add numpy
uv run python -c "import numpy as np; print(np.__version__)"
Source: NumPy installation instructions and uv documentation.
uv add records NumPy in pyproject.toml and in uv.lock, which makes the installation reproducible. uv pip install numpy
is the drop-in equivalent of pip inside an existing virtual environment. The official install page also mentions Pixi
(pixi add numpy) for project based workflows.
With conda or Miniforge
conda create -n analysis python=3.13 numpy
conda activate analysis
conda list --show-channel-urls numpy
Source: NumPy installation instructions and conda-forge documentation.
Conda can also install non-Python dependencies (compilers, CUDA, HDF5), which pip cannot. NumPy is available from the
defaults channel and from conda-forge. Mixing the two in one environment causes hard to diagnose conflicts; the
recommended setup is Miniforge, which uses conda-forge only, with strict channel priority. Anaconda’s terms of service
(updated on 2025-07-15) require a paid plan for organisations with more than 200 employees or contractors that use
Anaconda’s repository; this is not legal advice, so check the current terms. The complete reasoning is on
Setting Up a Data Science Environment.
System package managers and building from source
The official page lists brew install numpy, sudo apt install python3-numpy and choco install numpy as possible but
not recommended for most users: the package belongs to the system Python, usually lags several releases and cannot be
isolated per project. Building from source is for developers; it needs a C and C++ compiler, Meson and a BLAS/LAPACK
library, and the official documentation recommends binary wheels wherever they exist. Since NumPy 2.5 numpy.distutils
no longer exists and builds use Meson.
Which tool to choose
Checking what is installed
import sys
import numpy as np
print(np.__version__, sys.version_info[:2])
print(np.version.full_version, np.version.release)
np.show_config() # compiler, BLAS/LAPACK and SIMD information of this build
Output of the two print calls (the show_config() report that follows them is left out here, because its compiler,
BLAS/LAPACK and SIMD details differ per platform):
2.5.4 (3, 13)
2.5.4 True
Source: numpy.show_config.
np.__version__ is the string you should log with every experiment. np.version.release is False for development
builds. np.show_config() reports which BLAS and LAPACK implementation does the heavy linear algebra (OpenBLAS in the
Linux and Windows wheels, Accelerate on recent macOS builds) and which CPU features are used; install
pyyaml for the nicer output format the function prints a warning about otherwise. If import numpy fails with an
ImportError about C extensions, the usual causes are running the interpreter from inside the NumPy source directory,
or an environment where a package was compiled against a different NumPy than the one now installed; the official
troubleshooting guide for that error is linked in the references.
Import convention
import numpy as np
import numpy as np is the universal convention, used by the NumPy documentation, scikit-learn, pandas and virtually
all tutorials. Never use from numpy import *: it shadows the built-ins sum, min, max, abs, round and any
with NumPy functions that behave differently on non-array arguments.
Versions, Python support and release cadence
NumPy uses MAJOR.MINOR.PATCH numbering. Minor releases (2.4, 2.5) appear roughly every six months, around June and December; they may deprecate and, after at least two minor releases of warning, remove features. Patch releases (2.5.1 to 2.5.4) fix bugs and are published as needed. Each minor release supports a window of Python versions defined by the community policy SPEC 0, and NumPy drops the oldest Python as the window moves.
| NumPy | Supported Python | Notes |
|---|---|---|
2.0 (June 2024) |
3.9 to 3.12 |
First major release since 2006. Many aliases removed, new default promotion rules (NEP 50), new scalar repr (NEP 51), |
2.1 and 2.2 |
3.10 to 3.13 |
Experimental free-threaded CPython support (2.1), |
2.3 |
3.11 to 3.13 |
The mypy plugin is deprecated. |
2.4 |
3.11 to 3.14 |
Removal of |
2.5 (2.5.0 in June 2026; 2.5.4 in October 2026) |
3.12 to 3.14, with Python 3.15 support starting at its first release candidate |
|
2.6 (upcoming) |
not yet released |
Development version 2.6.dev0; the mypy plugin is removed there. Anything listed as 2.6 on this site is upcoming and must not be used in production. |
Source: NumPy release notes and NumPy 2.5.0 release notes.
Two practical consequences follow. First, a project that wants to support several NumPy versions should read the
minimum versions recommended by SPEC 0 (at the end of 2026: Python 3.13 and NumPy 2.3) instead of the oldest version
that happens to import. Second, the stable documentation at numpy.org/doc/stable is built from the 2.5.0 tag, so
the notes of the patch releases 2.5.1 to 2.5.4 are published only in the development documentation; the API
described in the stable pages is nevertheless the one you get with 2.5.4. When a statement on the website and the
release notes disagree, follow the release notes: for example the FFT page still says that single precision input is
promoted to double precision, while the 2.0 notes state that FFTs now compute natively in single and long double
precision.
Check your own interpreter before choosing a version: NumPy 2.5 does not install on Python 3.11 or older, and a very new Python (3.15 at the time of writing) may not have wheels for every library in your stack yet.
What changed from NumPy 2.0 to 2.5
This is the part that matters when you read older books, blog posts or Stack Overflow answers. Code written for NumPy
1.x mostly still runs, but some of it fails with an AttributeError, and some of it silently changes meaning.
Removed names and their replacements
NumPy 2.0 cleaned the main namespace. Using a removed name raises an AttributeError that names the replacement:
import numpy as np
x = np.float_(1)
AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.
Source: NumPy 2.0 migration guide.
| Removed | Use instead | Removed in |
|---|---|---|
|
|
2.0 |
|
|
2.0 |
|
|
2.0 |
|
|
2.0 |
|
|
2.0 |
|
the public API; the internals moved to the private |
2.0 |
|
|
2.4 |
|
|
2.4 |
|
|
2.5 |
Source: NumPy 2.0 migration guide and the release notes for 2.4 and 2.5.
The 2.0 aliases were removed in a single step, whereas later removals followed one or two minor releases of
DeprecationWarning. To see what your own code is about to lose, run it with warnings promoted to errors:
python -W error::DeprecationWarning script.py.
Ruff rule NPY201
The Ruff linter implements the migration for you. Its NPY201 rule (NumPy 2.0 deprecation) flags removed names and
fixes most of them automatically:
python -m pip install ruff
ruff check --select NPY201 --fix .
Source: Ruff rule NPY201 and NumPy 2.0 migration guide.
Review the diff afterwards: the fix cannot know that a library you call still expects the old behaviour, and it does
not rewrite np.float_ inside strings or generated code.
Behaviour changes that do not raise
import numpy as np
print(np.float64(3.0)) # 3.0
print(repr(np.float64(3.0))) # np.float64(3.0)
np.set_printoptions(legacy="1.25")
print(repr(np.float64(3.0))) # 3.0, the pre-2.0 repr
np.set_printoptions(legacy=False)
print(np.float32(3) + 3.0, (np.float32(3) + 3.0).dtype) # 6.0 float32
print((np.uint8(1) + 2).dtype) # uint8
try:
np.int8(1) + 1000
except OverflowError as e:
print("OverflowError:", e)
Output:
3.0
np.float64(3.0)
3.0
6.0 float32
uint8
OverflowError: Python integer 1000 out of bounds for int8
-
Scalar representation (NEP 51).
reprof a NumPy scalar now includes its type,np.float64(3.0). Code or doctests that compare printed output with the old3.0break;str()andprint()are unchanged. -
Promotion (NEP 50). Python scalars are "weak": they adopt the dtype of the NumPy operand instead of forcing a wider one, so
np.float32(3) + 3.0staysfloat32andnp.uint8(1) + 2staysuint8. NumPy scalars are "strong". A Python integer that does not fit raisesOverflowError. See Type Promotion (NEP 50) for the full rules. -
Default integer. The default integer is now 64-bit on 64-bit Windows as well (it was 32-bit
longbefore 2.0), sonp.arange(3).dtypeisint64on every 64-bit platform. -
np.bool.np.boolis again the canonical name of the boolean dtype (it isnp.bool_), after being removed in 1.24.
copy=False now raises
import numpy as np
try:
np.array([1, 2, 3], copy=False, dtype=float)
except ValueError as e:
print("ValueError:", e)
print(np.asarray([1, 2, 3], dtype=float)) # copy only if needed
print(np.array([1, 2, 3], dtype=float, copy=None)) # same meaning, explicit
Output:
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
[1. 2. 3.]
[1. 2. 3.]
In NumPy 1.x, copy=False meant "copy only if needed". In NumPy 2 it means "never copy" and raises if a copy is
unavoidable. The old meaning is spelled copy=None or, more commonly, np.asarray. A class that implements
__array__ must accept dtype=None, copy=None arguments.
A short list of what 2.1 to 2.5 added or deprecated
-
2.0:
StringDType(variable-width UTF-8 strings),np.strings,np.vecdot,np.linalg.matrix_norm,vector_normandsvdvals,.mT,quantile(weights=),sort(stable=True), array API standard support, thread-safe and context-localnp.errstate. -
2.1: experimental free-threaded Python support.
-
2.2:
np.matvecandnp.vecmat; the NEP 50 escape hatch of 2.0 is removed. -
2.3: mypy plugin deprecated.
-
2.4:
ndmaxargument fornp.array,np.roundalways copies,where=withoutout=warns,casting="same_value", removal ofnp.trapz,np.in1dandinterpolation=. -
2.5:
sort(descending=True)andargsort(descending=True),polyvalndfamily, pattern matching on arrays,np.distutilsgone; deprecations: settingarr.shape(usenp.reshape) andarr.dtype(usearr.view),np.fix(usenp.trunc),np.char.chararray, generic-unittimedelta64;eigandeigvalsnow always return complex arrays (useeighoreigvalshfor symmetric matrices);Generator.binomialandGenerator.multinomialcan return different samples for the same seed.
Source: NumPy release notes 2.0 to 2.5.
The full list lives on the dedicated migration and release pages of this section, which are written for reading end to end: see Migrating to NumPy 2.x and What’s New.
Making installed versions visible in your work
Record the version in every notebook, report or log, not just in requirements.txt:
import platform
import numpy as np
print(f"Python {platform.python_version()} on {platform.system()} {platform.machine()}")
print(f"NumPy {np.__version__}")
Output on the machine used for this page:
Python 3.13.18 on Darwin arm64
NumPy 2.5.4
Source: numpy.show_config.
A numerical result can differ between BLAS implementations in the last digits, so the version line is not decoration; it is part of the evidence needed to reproduce a number. See Reproducibility and MLOps Basics.
Common installation pitfalls
-
Installing into the system Python (
sudo pip install) breaks operating-system tools and is blocked on distributions that mark the interpreter as externally managed; use a virtual environment (see Environments and Externally Managed Pythons). -
Several interpreters. Jupyter, an IDE and a terminal can each use a different Python; print
sys.executableandnp.__file__to see which NumPy is imported. -
Packages built against NumPy 1.x. A compiled extension built for NumPy 1.x fails to import under NumPy 2 with an error such as "A module that was compiled using NumPy 1.x cannot be run in NumPy 2". Upgrade the extension; pinning
numpy<2is a stop gap that conflicts with newer Python versions. -
Mixing pip and conda in one environment replaces conda-managed files with pip ones. Install everything possible with conda first and use pip last, or use a single tool.
-
Oversubscribed BLAS threads when several processes each start a full thread pool; limit them with
threadpoolctlor theOPENBLAS_NUM_THREADSenvironment variable. -
Naming a script
numpy.pyshadows the library and makesimport numpyfail in confusing ways.
Source: NumPy 2.0 migration guide and NumPy thread safety.
Next: The Absolute Basics introduces the ndarray itself.