pmdarima is incompatible with numpy>=2.0.0
Describe the bug
Changes to numpy in v2.0.0 break the current version of pmdarima. Numpy 2.0 has significant breaking changes to its internal API, some of which are documented in their release notes.
To Reproduce
Install pmdarima without pinning numpy (i.e. install pmdarima with numpy>=2.0.0). Import pmdarima.
Versions
System:
python: 3.12.4 (main, Jun 18 2024, 10:50:53) [Clang 15.0.0 (clang-1500.3.9.4)]
executable: /.../.venv/bin/python
machine: macOS-14.5-arm64-arm-64bit
Python dependencies:
setuptools: 70.0.0
pip: None
sklearn: 1.5.0
statsmodels: 0.14.2
numpy: 1.26.4 # actually 2.0.0, but pmdarima won't import to get this output unless numpy is downgraded
scipy: 1.13.1 # actually 1.14.2, 1.13 doesn't support numpy 2.0
Cython: 3.0.10
pandas: 2.2.2
joblib: 1.4.2
pmdarima: 2.0.4
Expected Behavior
Pmdarima should import and run as normal.
Actual Behavior
Pmdarima does not import.
Python 3.12.4 (main, Jun 18 2024, 10:50:53) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pmdarima
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/.../.venv/lib/python3.12/site-packages/pmdarima/__init__.py", line 52, in <module>
from .arima import auto_arima, ARIMA, AutoARIMA, StepwiseContext, decompose
File "/.../.venv/lib/python3.12/site-packages/pmdarima/arima/__init__.py", line 5, in <module>
from .approx import *
File "/.../.venv/lib/python3.12/site-packages/pmdarima/arima/approx.py", line 9, in <module>
from ..utils.array import c, check_endog
File "/.../.venv/lib/python3.12/site-packages/pmdarima/utils/__init__.py", line 5, in <module>
from .array import *
File "/.../.venv/lib/python3.12/site-packages/pmdarima/utils/array.py", line 13, in <module>
from ._array import C_intgrt_vec
File "pmdarima/utils/_array.pyx", line 1, in init pmdarima.utils._array
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Additional Context
I'm not too familiar with the inner workings or development of pmdarima or numpy. Please let me know if there's any further information I can provide or if there's something specific I can look into to fix any potential issues.
Hi,
This issue may take a while to solve. The workaround is by downgrading the numpy version to 1.26.4 (and I have pandas 2.2.2, seems to work for me).
I appreciate the bug report and workaround! Looks like we need to be building against numpy 2.0. We'll work on this as time allows with day jobs. As always we are open to PRs!
Hi,
This issue may take a while to solve. The workaround is by downgrading the numpy version to 1.26.4 (and I have pandas 2.2.2, seems to work for me).
Yeah, I have done the same thing and it seems to work. but I find it useful to delete pip caches pip cache purge before installing the new version of numpy
thanks
I uninstalled numpy, purged the cache, and pip install numpy==1.26.4
I'm still getting ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject from import pmdarima as pm
Downgrading Numpy to numpy<2 on Python 3.12 worked here.
I just want to add that this is blocking support for Python 3.13. NumPy 1.26.4 limits support to Python<3.13. Support for Python 3.13 is added in NumPy 2.1.0.
Hi all, we at Darts are also looking now into adding support for numpy>=2.0.0. Since pmdarima is one of our dependencies, I wanted to ask whether you plan to add support in the near future?
Hey everyone, thanks for using pmdarima. I realize this has been open for some time, and has been a bit of a thorn in the side for everyone.
It's not a good excuse, but I have been very busy with my day job and (young) family lately. I'm going to commit to carve out some time for this as soon as possible. Hope to get this out for everyone soon. Thanks for your patience to date.
Shout-out to the devs for putting in the time and energy 🙏
In this case, shouldn't pmdarima make it clear to package managers (I'm using uv) that it's incompatible with numpy > v2.0.0? Is that done through the pyproject.toml file?
I've added both pmdarima and numpy as dependencies to my project and uv ended up installing numpy 2.2.2, resulting in pmdarima not working...
In this case, shouldn't
pmdarimamake it clear to package managers (I'm usinguv) that it's incompatible with numpy > v2.0.0? Is that done through the pyproject.toml file?
#581 should do this, but there isn’t a new tagged release yet.
Hi,
This issue may take a while to solve. The workaround is by downgrading the numpy version to 1.26.4 (and I have pandas 2.2.2, seems to work for me).
Thanks you!
For me what solved the problem was also downgrade numpy to 1.26.4 and pandas to 2.2.2
For me continue problem ... python 3.1.3 - downgrade numpy to 1.26.4 and pandas to 2.2.2
Is there a branch and project plan to get this onto numpy 2.0? I can probably help with some of the issues if they are enumerated and we have a test suite. I would volunteer to just chip away at it all.
@bfarzin I would be happy to review any PRs. You'll probably beat me to it
Hi, have you anyone tried this new pmdarima https://alkaline-ml.com/pmdarima/2.0.0/index.html ? It's slightly different to implement and run but I tried here and it's running good with most recent packages versions.
Does it work with numpy version >2.0 ?
Yes, my numpy is on 2.0.2 version
Yes, my numpy is on 2.0.2 version
@noeloliveira On which Python version are you working? Mine is currently at 3.12.4 (Windows 64-bit)
Hi,
This issue may take a while to solve. The workaround is by downgrading the numpy version to 1.26.4 (and I have pandas 2.2.2, seems to work for me).
@geee28 On which Python version and environment did you try out?
Is there a PR under active development that is open to contributions?
The Pull Requests page shows two Numpy 2.0.0+ branches and I am wanting to help get pmdarima to support this under Python 3.13.
The issue is related to the channel being used for installing pmdarima. Conda supports multiple channels, but for pmdarima, the recommended and most reliable channel is conda-forge. You should install the package using:
conda install -c conda-forge pmdarima
Additionally, please ensure you are using Python version 3.10, 3.11 or 3.12, as these are currently compatible with the latest releases of pmdarima. Using other Python versions may result in compatibility issues or failed installations.
To summarize:
- Use the
conda-forgechannel for installation. - Only Python 3.10, 3.11 or 3.12 are supported and compatible with the module.
If you follow these guidelines, pmdarima should install and work correctly in your environment.
For me the solution was python 3.10.17 with pandas and numpy version indicated here.
pip install numpy==1.26.4 && pip install pandas==2.2.2
Is that issue currently being worked on?
For those following the issue, we've been discussing on #601. We have candidate wheels for the next release shipped to test-pypi and should have it resolved soon.
Version 2.1.0 was just released and added support for Numpy 2+. For full list of changes, please refer to the release notes.
Thanks all for the patience, and big thanks to @ThibaultDECO and @aaronreidsmith in help getting this over the finish line.