Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
u3Izx9ql7vW4 opened this issue Jul 7, 2024 · 2 comments
Closed
3 tasks done
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@u3Izx9ql7vW4
Copy link

u3Izx9ql7vW4 commented Jul 7, 2024

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
...
@u3Izx9ql7vW4 u3Izx9ql7vW4 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 7, 2024
@Liam3851
Copy link
Contributor

Liam3851 commented Jul 8, 2024

Your error occurs when pandas imports the bottleneck optional dependency. Ensure you are using bottleneck 1.4.0 which includes numpy 2.0 support.

@mroeschke
Copy link
Member

Thanks for the issue but as mentioned, this is coming from bottleneck so closing as an upstream issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

3 participants