Skip to content

BUG: Pandas 2.2.2 incompatible with Numpy 2. AttributeError: _ARRAY_API not found Β #59203

@user529481

Description

@user529481

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd


A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 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 "/Users/dan/Library/Application Support/JetBrains/PyCharmCE2024.1/scratches/scratch_30.py", line 4, in <module>
    import pandas as pd
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/__init__.py", line 49, in <module>
    from pandas.core.api import (
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/api.py", line 28, in <module>
    from pandas.core.arrays import Categorical
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/arrays/__init__.py", line 1, in <module>
    from pandas.core.arrays.arrow import ArrowExtensionArray
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/arrays/arrow/__init__.py", line 5, in <module>
    from pandas.core.arrays.arrow.array import ArrowExtensionArray
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/arrays/arrow/array.py", line 50, in <module>
    from pandas.core import (
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/ops/__init__.py", line 8, in <module>
    from pandas.core.ops.array_ops import (
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/ops/array_ops.py", line 56, in <module>
    from pandas.core.computation import expressions
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/computation/expressions.py", line 21, in <module>
    from pandas.core.computation.check import NUMEXPR_INSTALLED
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/computation/check.py", line 5, in <module>
    ne = import_optional_dependency("numexpr", errors="warn")
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/compat/_optional.py", line 135, in import_optional_dependency
    module = importlib.import_module(name)
  File "/opt/homebrew/Cellar/[email protected]/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/homebrew/lib/python3.11/site-packages/numexpr/__init__.py", line 24, in <module>
    from numexpr.interpreter import MAX_THREADS, use_vml, __BLOCK_SIZE1__
AttributeError: _ARRAY_API not found

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 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 "/Users/dan/Library/Application Support/JetBrains/PyCharmCE2024.1/scratches/scratch_30.py", line 4, in <module>
    import pandas as pd
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/__init__.py", line 49, in <module>
    from pandas.core.api import (
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/api.py", line 28, in <module>
    from pandas.core.arrays import Categorical
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/arrays/__init__.py", line 1, in <module>
    from pandas.core.arrays.arrow import ArrowExtensionArray
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/arrays/arrow/__init__.py", line 5, in <module>
    from pandas.core.arrays.arrow.array import ArrowExtensionArray
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/arrays/arrow/array.py", line 64, in <module>
    from pandas.core.arrays.masked import BaseMaskedArray
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/arrays/masked.py", line 60, in <module>
    from pandas.core import (
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/core/nanops.py", line 52, in <module>
    bn = import_optional_dependency("bottleneck", errors="warn")
  File "/opt/homebrew/lib/python3.11/site-packages/pandas/compat/_optional.py", line 135, in import_optional_dependency
    module = importlib.import_module(name)
  File "/opt/homebrew/Cellar/[email protected]/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/homebrew/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

Issue Description

Unable to import Pandas after upgrading to 2.2.2 with Numpy 2.0.0.

Expected Behavior

That error should not occur as Numpy 2 is supposed to be supported in Pandas 2.2.2 as per release notes(https://pandas.pydata.org/docs/whatsnew/v2.2.2.html)

Installed Versions

Unable to run pd.show_versions() as it throws error above when importing pandas

> pip list 
...
pandas                    2.2.2
numpy                     2.0.0
pyarrow                   16.1.0
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions