Fundamental package for numerical computing in Python. Current version is 2.4.3 (Mar 2026). NumPy 2.0 (Jun 2024) was a landmark major release with ABI breakage, ~100 removed namespace members, and type promotion changes (NEP 50). Packages built against NumPy 1.x will not import with NumPy 2.x.
pip install numpyVerified import paths — ran on the pinned version, not inferred.
Basic array creation and operations. Use new random Generator API.
Upgrade all binary dependencies to versions built against NumPy 2.x. Check https://github.com/numpy/numpy/issues/24300 for ecosystem compatibility status.
Replace with explicit dtypes: np.float_ → np.float64, np.int_ → np.intp, np.complex_ → np.complex128, np.bool_ → np.bool_, np.Inf → np.inf, np.NAN → np.nan. Use ruff --select NPY201 to auto-fix.
Audit mixed-precision arithmetic. Explicitly cast where float64 precision is required: np.float64(3) + arr or arr.astype(np.float64).
Access all public members from the main np namespace. Never import from np.core or np._core directly.
Use np.random.default_rng(seed) to create a Generator. Replace np.random.randn(n) with rng.standard_normal(n), np.random.randint(a, b) with rng.integers(a, b).
Use Python float or np.float64 explicitly. Same for np.int → int or np.int64, np.complex → complex or np.complex128.
For variable-length strings: arr = np.array(['hello', 'world'], dtype=np.dtypes.StringDType()). np.string_ creates fixed-width byte arrays.
Upgrade the affected downstream package to a version compiled against NumPy 2.x, or downgrade NumPy to a version compatible with the package (e.e. `pip install 'numpy<2'`). If it's a locally built package, it needs to be recompiled against the current NumPy 2.x installation.
Try uninstalling and reinstalling NumPy (`pip uninstall numpy && pip install numpy`). If the issue persists, explicitly upgrade or downgrade NumPy to a compatible version for your other packages (`pip install 'numpy<2'` or `pip install numpy --upgrade`), or create a clean virtual environment and reinstall all dependencies.
Install NumPy using pip (`pip install numpy`). If already installed, ensure you are running your script with the Python interpreter where NumPy is installed, or activate the correct virtual environment.
Replace `np.rank(array)` with `array.ndim` or `np.ndim(array)` to get the number of dimensions. For other removed attributes, consult the NumPy 2.0 migration guide for the correct replacement (e.g., `np.prod` for `np.product`).
Ensure all array elements have a consistent data type before performing the operation, typically by explicitly casting them using the `.astype()` method (e.g., `arr.astype(float)`). For type promotion issues in NumPy 2.0, explicitly cast to the desired precision or use Python scalars.
No dependency data recorded yet.