PMDARIMA: unable to use pmdarima in google collab
Describe the bug
Description:
I am encountering a persistent ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject error specifically when importing auto_arima from the pmdarima library in Google Colab. This error occurs regardless of the Python environment, NumPy version, or installation method used. Critically, this error persists even when running the code inside a clean Docker container, indicating a potential issue with the pmdarima package itself.
https://colab.research.google.com/drive/167-KS2KWsIG-DT4aXsf3kkGf_osflQg0?usp=sharing
To Reproduce
import numpy as np import pandas as pd
Create a simple monthly time series with 36 data points
ts = pd.Series( np.random.randn(36), index=pd.date_range(start='2020-01-01', periods=36, freq='MS') )
# This import triggered the binary incompatibility error
from pmdarima import auto_arima
Fit an ARIMA model (with seasonal component)
model = auto_arima(ts, seasonal=True, m=12, trace=True, error_action='ignore', suppress_warnings=True)
print("ARIMA order:", model.order) print("Seasonal order:", model.seasonal_order)
Versions
pmdarima-2.0.4
Linux-6.1.85+-x86_64-with-glibc2.35
Python 3.11.11 (main, Dec 4 2024, 08:55:07) [GCC 11.4.0]
NumPy 2.0.2
SciPy 1.14.1
Scikit-Learn 1.6.1
Statsmodels 0.14.4
Expected Behavior
The model should predict my data.
Actual Behavior
Expected Output
Key Information:
Error: ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Trigger: from pmdarima import auto_arima
Environment: Google Colab (Ubuntu 22.04.4 LTS, Python 3.11.11)
Persistence: Error persists even in a Docker container with python 3.9 and numpy 1.23. Troubleshooting: Extensive troubleshooting steps have been taken, including NumPy downgrades, Conda environments, and installation from source.
Additional Context
Request:
Please investigate this issue, as it appears to be a bug within the pmdarima package or a fundamental incompatibility that persists even in isolated Docker environments.
Sources and related content
Output of import statsmodels.api as sm; sm.show_versions()
I had the same issue, too. I switched to Deepnote, and it worked. It has something to do with the libraries on Google Colab
Hi. I'm having the same issue, I'm unable to use pmdarima in a google colab notebook.
same but on visual studio
Ancgate, your comment is helpful, thanks.
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.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.
Took chatgpts help to get it run on google colab for now
%pip install numpy==1.24.4 --force-reinstall --no-cache-dir ( need to run this once .. this will ask for a restart of the enivronment )
then run %pip install pmdarima --no-cache-dir
I had the same issue, spent hours trying to fix, it's due to dependencies conflicts, very tough one. I've ended up installing these and finally managed to have it working. Make sure to restart the runtime session after installing them
`
Clean up first (if not a fresh environment)
!pip uninstall -y numpy pandas scikit-learn pmdarima Cython packaging setuptools statsmodels scipy mapie
Let pmdarima install what it needs
!pip install pmdarima==2.0.4
Then install others, being careful not to downgrade/upgrade critical pmdarima deps
!pip install pandas==2.2.2 scikit-learn==1.6.1 statsmodels==0.14.4 setuptools==69.5.1 packaging==23.2 Cython==3.1.2 scipy==1.11.4 mapie==0.6.0 `
thanks @Ahmad-Th