AttributeError: _ARRAY_API not found / numpy.dtype size changed (pandas, NumPy 2)

AttributeError: _ARRAY_API not found and ValueError: numpy.dtype size changed both mean a compiled package built for NumPy 1.x was loaded under NumPy 2. With pandas 3 the culprit is often an old optional package such as bottleneck, and pandas still runs. Measured with real pip installs.

1. Old pandas + NumPy 2: "numpy.dtype size changed"

$ pip install -q "pandas==2.1.4" "numpy==1.26.4"
$ pip install -q "numpy==2.3.4"
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pandas 2.1.4 requires numpy<2,>=1.23.2; python_version == "3.11", but you have numpy 2.3.4 which is incompatible.
$ python -c "import pandas"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/pandas/__init__.py", line 46, in <module>
    from pandas.core.api import (
  File "/usr/local/lib/python3.11/site-packages/pandas/core/api.py", line 1, in <module>
    from pandas._libs import (
  File "/usr/local/lib/python3.11/site-packages/pandas/_libs/__init__.py", line 18, in <module>
    from pandas._libs.interval import Interval
  File "interval.pyx", line 1, in init pandas._libs.interval
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

pandas 2.1.4 declares numpy<2, yet pip installed NumPy 2.3.4 anyway: it printed an ERROR about the conflict but exited normally. The next import pandas fails because pandas' compiled parts were built against the NumPy 1 C layout (88 vs 96 bytes). The same thing happens when another package's requirements pull NumPy 2 in.

2. New pandas + an old optional package: "_ARRAY_API not found"

$ pip install -q "pandas==3.1.0" "numpy==2.3.4" "bottleneck==1.3.7"
$ python -c "import pandas as pd; print(pd.Series([1, 2]).sum())"

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.3.4 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/pandas/__init__.py", line 46, in <module>
    from pandas.core.api import (
  File "/usr/local/lib/python3.11/site-packages/pandas/core/api.py", line 27, in <module>
    from pandas.core.arrays import Categorical
  File "/usr/local/lib/python3.11/site-packages/pandas/core/arrays/__init__.py", line 1, in <module>
    from pandas.core.arrays.arrow import ArrowExtensionArray
  File "/usr/local/lib/python3.11/site-packages/pandas/core/arrays/arrow/__init__.py", line 5, in <module>
    from pandas.core.arrays.arrow.array import ArrowExtensionArray
  File "/usr/local/lib/python3.11/site-packages/pandas/core/arrays/arrow/array.py", line 97, in <module>
    from pandas.core.arrays.masked import BaseMaskedArray
  File "/usr/local/lib/python3.11/site-packages/pandas/core/arrays/masked.py", line 63, in <module>
    from pandas.core import (
  File "/usr/local/lib/python3.11/site-packages/pandas/core/nanops.py", line 58, in <module>
    bn = import_optional_dependency("bottleneck", errors="warn")
  File "/usr/local/lib/python3.11/site-packages/pandas/compat/_optional.py", line 158, in import_optional_dependency
    module = importlib.import_module(name)
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.11/site-packages/bottleneck/__init__.py", line 7, in <module>
    from .move import (move_argmax, move_argmin, move_max, move_mean, move_median,
AttributeError: _ARRAY_API not found
3

Here pandas 3.1.0 itself is fine. The banner and AttributeError: _ARRAY_API not found come from bottleneck 1.3.7, an optional speed-up pandas tries to import (see the import_optional_dependency("bottleneck", errors="warn") frame). pandas carries on without it: the script still printed 3 and exited with status 0. So the scary traceback is noise in this case, but the culprit is always the package in the last frame above the AttributeError, not pandas or NumPy. We got the same banner from numexpr 2.8.7 and scipy 1.11.4 (scipy then raised ImportError: numpy.core.multiarray failed to import and stopped).

3. Fix: upgrade the package named in the traceback

$ pip check
No broken requirements found.
$ pip install -q -U pandas bottleneck
$ pip check
No broken requirements found.
$ python -c "import numpy, pandas, bottleneck; print(numpy.__version__, pandas.__version__, bottleneck.__version__)"
2.3.4 3.1.0 1.6.0

pip check found nothing wrong, because bottleneck 1.3.7 does not declare a NumPy upper bound, so you cannot rely on it to spot this. Upgrading the package from the last traceback frame (here bottleneck, to 1.6.0) removed the banner. For case 1, upgrade pandas: 2.2.2 is the first release whose metadata allows NumPy 2 (2.2.1 still pins numpy<2). If you cannot upgrade the old package, do what the banner says and pin python -m pip install "numpy<2" in that environment.

Related: numpy.dtype size changed, may indicate binary incompatibility · pip installed into the wrong Python · Missing optional dependency 'openpyxl' · SettingWithCopyWarning.

Frequently asked questions

How do I fix AttributeError: _ARRAY_API not found?

Upgrade the package named in the last traceback frame above the error (for example bottleneck or numexpr). If you cannot, install numpy<2 in that environment.

What does numpy.dtype size changed, may indicate binary incompatibility mean?

A package (often an old pandas such as 2.1.x) was compiled against NumPy 1 and is being imported with NumPy 2. Upgrade pandas to 2.2.2 or later, or pin numpy<2.

Why didn't pip prevent the incompatible install?

pip reports the conflict as an ERROR line but still installs, and packages without an upper bound such as bottleneck 1.3.7 pass pip check.

Written with AI assistance. Measured on 2026-10-23 in the python:3.11-alpine Docker image with NumPy 2.3.4, pandas 2.1.4 / 3.1.0 and bottleneck 1.3.7 / 1.6.0 (binary wheels only). Shell transcripts pasted unedited. PlainTables is our extension; Python, pandas and NumPy are free.