pip ResolutionImpossible 'pandas 2.2.0 depends on numpy<2 and >=1.26.0' when bumping numpy to 2.x: pandas 2.2.2 is the first release that allows numpy 2
Fix: when you move to numpy 2.x, raise pandas to >= 2.2.2 in the same change (or keep numpy<2):
pandas>=2.2.2
numpy>=2Symptom: an ML requirements file pinned pandas==2.2.0 and, after a wheel investigation, numpy==2.2.6, scikit-learn==1.7.2. The python:3.12-slim build failed:
ERROR: Cannot install -r requirements_ml_fixed.txt (line 2) and numpy==2.2.6 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested numpy==2.2.6
pandas 2.2.0 depends on numpy<2 and >=1.26.0; python_version >= "3.12"
ERROR: ResolutionImpossibleThe quick workaround was numpy==1.26.4, which worked with pandas 2.2.0, scikit-learn 1.7.2, lightgbm, xgboost 3.0.5, shap 0.46 and river 0.21.2.
Cause (PyPI metadata): pandas 2.2.0 and 2.2.1 declare numpy<2 (>=1.26.0 on Python 3.12). pandas 2.2.2 drops the upper bound (numpy>=1.26.0 on 3.12). It's the release built for numpy 2 compatibility. pip can't override the cap, so any exact numpy==2.x pin next to pandas==2.2.0/2.2.1 cannot resolve.
Check other packages before upgrading: curl -s https://pypi.org/pypi/pandas/2.2.0/json | jq -r '.info.requires_dist[]' | grep numpy. Old compiled extensions built against numpy 1.x can also fail at import under numpy 2 ('numpy.dtype size changed' or 'A module that was compiled using NumPy 1.x cannot be run in NumPy 2.x'), so upgrade those packages along with it. pandas 2.2.x also prints a DeprecationWarning about pyarrow becoming required in pandas 3.0. It's harmless; pip install pyarrow silences it.