pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
42.62k stars 17.57k forks source link

BUG: Failed to import pandas <2.1.0 witn numpy >=2.0.0 #59052

Closed yfa-vagelis closed 2 weeks ago

yfa-vagelis commented 2 weeks ago

Pandas version checks

Reproducible Example

In a clean python 3.11 environment install pandas==2.0.3

 py -3.11 -m venv venv
.\venv\Scripts\Activate.ps1
pip install pandas==2.0.3

This install pandas==2.0.3 and numpy==2.0.0.

Start python and simply import pandas, throws an error

py
import pandas
>>> ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject


### Issue Description

Pandas 2.0.* has incorrect numpy dependency.

### Expected Behavior

Install numpy<2.0.0

### Installed Versions

Cannont import pandas and therefore I cannot run this command.
asishm commented 2 weeks ago

pandas 2.2.2 is the first version that is compatible with numpy 2.0. I'm not sure how feasible it is to edit the metadata to add in an upper bound on numpy version to an already released version. cc @lithomas1

https://pandas.pydata.org/docs/whatsnew/v2.2.2.html#pandas-2-2-2-is-now-compatible-with-numpy-2-0

lithomas1 commented 2 weeks ago

We cannot retroactively change packaging metadata on previously released versions. (IIRC, a pin was put in place in time for the pandas 2.1.x series)

You should pin your numpy version to less than 2, or install pandas 2.2.2 as @asishm mentions.

Pinning numpy for future releases of pandas is something that we'll definitely consider (but figuring out which version of numpy to pin to is a non-trivial)

ajayrgb commented 2 weeks ago

Could you publish another release from the 1.x branch that pins numpy to <2?