Answers for LLM inference engineers

AttributeError: module 'numpy' has no attribute 'float_' (or 'float', 'NaN', 'product', any name): which NumPy removed it and what to use

NumPy 1.24.0 (2022-12-18) removed np.float, np.int, np.bool, np.object, np.str, np.complex, np.long and np.unicode: use the Python builtins (float, int) or NumPy types (np.float64). NumPy 2.0.0 (2024-06-16) removed 77 more, among them np.float_ (use np.float64), np.NaN (np.nan), np.Inf (np.inf), np.complex_ (np.complex128) and np.product (np.prod). 2.4 removed np.trapz and np.in1d, 2.5 np.row_stack. If the error comes from a library you did not write, upgrade the library or pin NumPy below the release that removed the name. Paste the error below for the release-by-release answer.

Published 2026-11-25 · 15 NumPy releases installed and run, 1.19.5 to 2.5.5 (1,545 attribute accesses) · how

Examples:

Runs in your browser on the data in this page (numpy_attrs.json); nothing you paste is sent anywhere.

Which release removed it, and what replaces it?

92 names that worked in one NumPy release and fail in a later one. "Instead" is NumPy's own text: the error message where it has one, otherwise the deprecation warning the name gave before it went.

NameFails fromInstead
np.asscalar1.23np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
np.bool1.24`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
np.complex1.24`np.complex` was a deprecated alias for the builtin `complex`. To avoid this error in existing code, use `complex` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.complex128` here.
np.float1.24`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
np.int1.24`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
np.long1.24`np.long` is a deprecated alias for `np.compat.long`. To silence this warning, use `np.compat.long` by itself. In the likely event your code does not need to work on Python 2 you can use the builtin `int` for which `np.compat.long` is itself an alias. Doing this will not modify any behaviour and is safe. When replacing `np.long`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
np.MachAr1.24`np.MachAr` is deprecated (NumPy 1.22).
np.object1.24`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe.
np.str1.24`np.str` was a deprecated alias for the builtin `str`. To avoid this error in existing code, use `str` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.str_` here.
np.typeDict1.24`np.typeDict` is a deprecated alias for `np.sctypeDict`.
np.unicode1.24`np.unicode` is a deprecated alias for `np.compat.unicode`. To silence this warning, use `np.compat.unicode` by itself. In the likely event your code does not need to work on Python 2 you can use the builtin `str` for which `np.compat.unicode` is itself an alias. Doing this will not modify any behaviour and is safe. If you specifically wanted the numpy scalar type, use `np.str_` here. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
np.add_docstring2.0`np.add_docstring` was removed in the NumPy 2.0 release. It's still available as `np.lib.add_docstring`.
np.add_newdoc2.0`np.add_newdoc` was removed in the NumPy 2.0 release. It's still available as `np.lib.add_newdoc`.
np.add_newdoc_ufunc2.0`np.add_newdoc_ufunc` was removed in the NumPy 2.0 release. It's an internal function and doesn't have a replacement.
np.alltrue2.0`np.alltrue` was removed in the NumPy 2.0 release. Use `np.all` instead.
np.asfarray2.0`np.asfarray` was removed in the NumPy 2.0 release. Use `np.asarray` with a proper dtype instead.
np.bool82.0`np.bool8` is a deprecated alias for `np.bool_`. (Deprecated NumPy 1.24)
np.byte_bounds2.0`np.byte_bounds` was removed in the NumPy 2.0 release. Now it's available under `np.lib.array_utils.byte_bounds`
np.bytes02.0`np.bytes0` is a deprecated alias for `np.bytes_`. (Deprecated NumPy 1.24)
np.cast2.0`np.cast` was removed in the NumPy 2.0 release. Use `np.asarray(arr, dtype=dtype)` instead.
np.cfloat2.0`np.cfloat` was removed in the NumPy 2.0 release. Use `np.complex128` instead.
np.clongfloat2.0`np.clongfloat` was removed in the NumPy 2.0 release. Use `np.clongdouble` instead.
np.compare_chararrays2.0`np.compare_chararrays` was removed in the NumPy 2.0 release. It's still available as `np.char.compare_chararrays`.
np.compat2.0`np.compat` was removed in the NumPy 2.0 release. There's no replacement, as Python 2 is no longer supported.
np.complex_2.0`np.complex_` was removed in the NumPy 2.0 release. Use `np.complex128` instead.
np.cumproduct2.0`cumproduct` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `cumprod` instead.
np.DataSource2.0`np.DataSource` was removed in the NumPy 2.0 release. It's still available as `np.lib.npyio.DataSource`.
np.deprecate2.0`np.deprecate` was removed in the NumPy 2.0 release. Emit `DeprecationWarning` with `warnings.warn` directly, or use `warnings.deprecated`.
np.deprecate_with_doc2.0`np.deprecate_with_doc` was removed in the NumPy 2.0 release. Emit `DeprecationWarning` with `warnings.warn` directly, or use `warnings.deprecated`.
np.disp2.0`np.disp` was removed in the NumPy 2.0 release. Use your own printing function instead.
np.fastCopyAndTranspose2.0`np.fastCopyAndTranspose` was removed in the NumPy 2.0 release. Use `arr.T.copy()` instead.
np.find_common_type2.0`np.find_common_type` was removed in the NumPy 2.0 release. Use `numpy.promote_types` or `numpy.result_type` instead. To achieve semantics for the `scalar_types` argument, use `numpy.result_type` and pass the Python values `0`, `0.0`, or `0j`.
np.float_2.0`np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.
np.format_parser2.0`np.format_parser` was removed in the NumPy 2.0 release. It's still available as `np.rec.format_parser`.
np.fv2.0In accordance with NEP 32, the function fv was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.get_array_wrap2.0`np.get_array_wrap` was removed in the NumPy 2.0 release.
np.geterrobj2.0`np.geterrobj` was removed in the NumPy 2.0 release. Use the np.errstate context manager instead.
np.Inf2.0`np.Inf` was removed in the NumPy 2.0 release. Use `np.inf` instead.
np.Infinity2.0`np.Infinity` was removed in the NumPy 2.0 release. Use `np.inf` instead.
np.infty2.0`np.infty` was removed in the NumPy 2.0 release. Use `np.inf` instead.
np.int02.0`np.int0` is a deprecated alias for `np.intp`. (Deprecated NumPy 1.24)
np.ipmt2.0In accordance with NEP 32, the function ipmt was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.irr2.0In accordance with NEP 32, the function irr was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.issctype2.0`np.issctype` was removed in the NumPy 2.0 release. Use `issubclass(rep, np.generic)` instead.
np.issubclass_2.0`np.issubclass_` was removed in the NumPy 2.0 release. Use `issubclass` builtin instead.
np.issubsctype2.0`np.issubsctype` was removed in the NumPy 2.0 release. Use `np.issubdtype` instead.
np.longcomplex2.0`np.longcomplex` was removed in the NumPy 2.0 release. Use `np.clongdouble` instead.
np.longfloat2.0`np.longfloat` was removed in the NumPy 2.0 release. Use `np.longdouble` instead.
np.lookfor2.0`np.lookfor` was removed in the NumPy 2.0 release. Search NumPy's documentation directly.
np.mat2.0`np.mat` was removed in the NumPy 2.0 release. Use `np.asmatrix` instead.
np.math2.0`np.math` is a deprecated alias for the standard library `math` module (Deprecated Numpy 1.25). Replace usages of `np.math` with `math`
np.maximum_sctype2.0`np.maximum_sctype` was removed in the NumPy 2.0 release. Use a specific dtype instead. You should avoid relying on any implicit mechanism and select the largest dtype of a kind explicitly in the code.
np.mirr2.0In accordance with NEP 32, the function mirr was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.msort2.0msort is deprecated, use np.sort(a, axis=0) instead
np.NaN2.0`np.NaN` was removed in the NumPy 2.0 release. Use `np.nan` instead.
np.nbytes2.0`np.nbytes` was removed in the NumPy 2.0 release. Use `np.dtype(<dtype>).itemsize` instead.
np.NINF2.0`np.NINF` was removed in the NumPy 2.0 release. Use `-np.inf` instead.
np.nper2.0In accordance with NEP 32, the function nper was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.npv2.0In accordance with NEP 32, the function npv was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.NZERO2.0`np.NZERO` was removed in the NumPy 2.0 release. Use `-0.0` instead.
np.obj2sctype2.0`np.obj2sctype` was removed in the NumPy 2.0 release. Use `np.dtype(obj).type` instead.
np.object02.0`np.object0` is a deprecated alias for ``np.object0` is a deprecated alias for `np.object_`. `object` can be used instead. (Deprecated NumPy 1.24)`. (Deprecated NumPy 1.24)
np.PINF2.0`np.PINF` was removed in the NumPy 2.0 release. Use `np.inf` instead.
np.pmt2.0In accordance with NEP 32, the function pmt was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.ppmt2.0In accordance with NEP 32, the function ppmt was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.product2.0`product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
np.pv2.0In accordance with NEP 32, the function pv was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.PZERO2.0`np.PZERO` was removed in the NumPy 2.0 release. Use `0.0` instead.
np.rate2.0In accordance with NEP 32, the function rate was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
np.recfromcsv2.0`np.recfromcsv` was removed in the NumPy 2.0 release. Use `np.genfromtxt` with comma delimiter instead.
np.recfromtxt2.0`np.recfromtxt` was removed in the NumPy 2.0 release. Use `np.genfromtxt` instead.
np.round_2.0`np.round_` was removed in the NumPy 2.0 release. Use `np.round` instead.
np.safe_eval2.0`np.safe_eval` was removed in the NumPy 2.0 release. Use `ast.literal_eval` instead.
np.sctype2char2.0`np.sctype2char` was removed in the NumPy 2.0 release. Use `np.dtype(obj).char` instead.
np.sctypes2.0`np.sctypes` was removed in the NumPy 2.0 release. Access dtypes explicitly instead.
np.set_numeric_ops2.0`np.set_numeric_ops` was removed in the NumPy 2.0 release. For the general case, use `PyUFunc_ReplaceLoopBySignature`. For ndarray subclasses, define the ``__array_ufunc__`` method and override the relevant ufunc.
np.set_string_function2.0`np.set_string_function` was removed in the NumPy 2.0 release. Use `np.set_printoptions` instead with a formatter for custom printing of NumPy objects.
np.seterrobj2.0`np.seterrobj` was removed in the NumPy 2.0 release. Use the np.errstate context manager instead.
np.singlecomplex2.0`np.singlecomplex` was removed in the NumPy 2.0 release. Use `np.complex64` instead.
np.sometrue2.0`np.sometrue` was removed in the NumPy 2.0 release. Use `np.any` instead.
np.source2.0`np.source` was removed in the NumPy 2.0 release. Use `inspect.getsource` instead.
np.str02.0`np.str0` is a deprecated alias for `np.str_`. (Deprecated NumPy 1.24)
np.string_2.0`np.string_` was removed in the NumPy 2.0 release. Use `np.bytes_` instead.
np.tracemalloc_domain2.0`np.tracemalloc_domain` was removed in the NumPy 2.0 release. It's now available from `np.lib`.
np.uint02.0`np.uint0` is a deprecated alias for `np.uintp`. (Deprecated NumPy 1.24)
np.unicode_2.0`np.unicode_` was removed in the NumPy 2.0 release. Use `np.str_` instead.
np.void02.0`np.void0` is a deprecated alias for `np.void`. (Deprecated NumPy 1.24)
np.who2.0`np.who` was removed in the NumPy 2.0 release. Use an IDE variable explorer or `locals()` instead.
np.in1d2.4`in1d` is deprecated. Use `np.isin` instead.
np.trapz2.4`trapz` is deprecated. Use `trapezoid` instead, or one of the numerical integration functions in `scipy.integrate`.
np.chararray2.5`np.chararray` is deprecated and will be removed from the main namespace in the future. Use an array with a string or bytes dtype instead.
np.row_stack2.5`row_stack` alias is deprecated. Use `np.vstack` directly.

NumPy 2.4.0 was yanked from PyPI, so the 2.4 row was measured on 2.4.1. np.bool and np.long fail in 1.24 to 1.26 and work again from 2.0, as NumPy types.

How was this measured?

Each of 15 NumPy releases was installed from PyPI in its own environment and getattr(numpy, name) was run for every name, recording whether it worked, which warning it gave, and the exact AttributeError text. Releases: 1.19.5 (Python 3.9), 1.20.0 (Python 3.9), 1.21.0 (Python 3.9), 1.22.0 (Python 3.10), 1.23.0 (Python 3.10), 1.24.0 (Python 3.11), 1.25.0 (Python 3.11), 1.26.0 (Python 3.11), 2.0.0 (Python 3.12), 2.1.0 (Python 3.12), 2.2.0 (Python 3.12), 2.3.0 (Python 3.12), 2.4.1 (Python 3.12), 2.5.0 (Python 3.12), 2.5.5 (Python 3.12). The names are those in the tables NumPy's module __getattr__ answers from (__deprecated_attrs__, __expired_functions__, __former_attrs__, __future_scalars__, numpy/_expired_attrs_2_0.py) in the first release of every minor from 1.16, plus a few removed without an entry. Those tables were also read from the source at the release tags: all 609 entries predict what the installed release did, with no mismatch.

The table covers access to the attribute. Some names (np.product in 1.25 and 1.26) warn only when called, so they show here as "works".

Questions

How do I fix "module 'numpy' has no attribute 'float'" (or 'int', 'bool', 'object')?

NumPy 1.24.0 (2022-12-18) removed these aliases of the Python builtins; 1.20 to 1.23 warned. Use float, int, bool, object (the builtins) or the NumPy types np.float64, np.int64, np.bool_. From 1.25 the error explains this. np.bool and np.long exist again from 2.0, now as NumPy types (np.bool is np.bool_). If the error comes from a library, upgrade it, or pin numpy<1.24.

How do I fix "`np.float_` was removed in the NumPy 2.0 release"?

Use np.float64. NumPy 2.0.0 (2024-06-16) removed 77 names; 54 of them answer with a message naming the replacement (np.NaN to np.nan, np.Inf to np.inf, np.complex_ to np.complex128, np.string_ to np.bytes_, np.unicode_ to np.str_). The others fail with the plain AttributeError; the table on this page gives their replacement from the deprecation warning they showed before.

Why does "No module named 'numpy._core'" appear?

numpy._core exists from NumPy 2.0 (numpy.core before). A pickle, joblib or model file written with NumPy 2 refers to numpy._core, so loading it under NumPy 1.x fails. Load it with NumPy 2, or write it again under the NumPy you load it with.

What does "A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0" mean?

An installed package has a C extension built against NumPy 1.x. NumPy 2 prints this from numpy/core/_multiarray_umath.py and suggests the two fixes: upgrade that package to a release built for NumPy 2, or pin numpy<2.

np.trapz and np.in1d stopped working. What changed?

NumPy 2.4 removed them (2.4.0 was yanked from PyPI; 2.4.1 is the first 2.4 release). Use np.trapezoid and np.isin. NumPy 2.5 removed np.row_stack (use np.vstack) and np.chararray from the main namespace.

Sources

The same data as JSON: numpy_attrs.json, licensed CC BY 4.0.

Related: "No module named 'torchvision.transforms.functional_tensor'" · "cannot import name ... from 'transformers'" · "... from 'pydantic'".