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

Current version does not work with numpy 2.0 #1685

Closed
2 of 3 tasks
jamescooke opened this issue Jun 16, 2024 · 5 comments
Closed
2 of 3 tasks

Current version does not work with numpy 2.0 #1685

jamescooke opened this issue Jun 16, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@jamescooke
Copy link

jamescooke commented Jun 16, 2024

Check list

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandera.
  • (optional) I have confirmed this bug exists on the main branch of pandera.

Current behaviour

Installing latest pandera and attempting to import will cause the error.

In a clean virtualenv with Python 3.12, install Panderas and then run the repl:

pip install pandera
python

Now just import pandera:

import pandera

And the following is received:

>>> import pandera
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/tmp.dMYyAaK7ge/venv312/lib/python3.12/site-packages/pandera/__init__.py", line 5, in <module>
    import pandera.backends
  File "/tmp/tmp.dMYyAaK7ge/venv312/lib/python3.12/site-packages/pandera/backends/__init__.py", line 4, in <module>
    import pandera.backends.base.builtin_checks
  File "/tmp/tmp.dMYyAaK7ge/venv312/lib/python3.12/site-packages/pandera/backends/base/builtin_checks.py", line 14, in <module>
    from pandera.api.checks import Check
  File "/tmp/tmp.dMYyAaK7ge/venv312/lib/python3.12/site-packages/pandera/api/checks.py", line 17, in <module>
    from pandera.strategies.base_strategies import SearchStrategy
  File "/tmp/tmp.dMYyAaK7ge/venv312/lib/python3.12/site-packages/pandera/strategies/__init__.py", line 3, in <module>
    from pandera.strategies.pandas_strategies import *
  File "/tmp/tmp.dMYyAaK7ge/venv312/lib/python3.12/site-packages/pandera/strategies/pandas_strategies.py", line 42, in <module>
    from pandera.engines import numpy_engine, pandas_engine
  File "/tmp/tmp.dMYyAaK7ge/venv312/lib/python3.12/site-packages/pandera/engines/pandas_engine.py", line 757, in <module>
    np.string_,
    ^^^^^^^^^^
  File "/tmp/tmp.dMYyAaK7ge/venv312/lib/python3.12/site-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.string_` was removed in the NumPy 2.0 release. Use `np.bytes_` instead.. Did you mean: 'strings'?

This appears to be the source of the problem:

Expected behaviour

Pandera should be importable and usable.

Desktop (please complete the following information):

  • OS: Linux
  • Browser: n/a
  • Version: python 3.12, with pandas==2.2.2, pandera==0.19.3, numpy==2.0.0
@jamescooke jamescooke added the bug Something isn't working label Jun 16, 2024
@gabrieldinizsm
Copy link

Facing the same issue using pandera[polars]

OS: Windows 10
Browser: n/a
Version: python 3.12.1, with pandas==2.2.2, pandera==0.19.3, numpy==2.0.0

@MichaelMachu
Copy link

We have the same issue, right now only option is to downgrade numpy to the previous version.

For us we have chosen the numpy==1.26.4 which works.

@jamescooke
Copy link
Author

Oh that's a good point @MichaelMachu - I also found a work around by pinning numpy<2 in my project. Then Pandera works fine again.

khaeru added a commit to iiasa/message_ix that referenced this issue Jun 17, 2024
khaeru added a commit to iiasa/message_ix that referenced this issue Jun 17, 2024
khaeru added a commit to iiasa/message-ix-models that referenced this issue Jun 17, 2024
khaeru added a commit to iiasa/message_ix that referenced this issue Jun 17, 2024
khaeru added a commit to iiasa/message-ix-models that referenced this issue Jun 17, 2024
@cosmicBboy
Copy link
Collaborator

This is a duplicate of #1656. fyi, this PR should address this issue: #1690

@jamescooke
Copy link
Author

@cosmicBboy Sorry for the duplicate 😔 close this off as required 🙏🏻.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants