statsmodels and NumPy 2 compatibility (tested)
statsmodels 0.14.1 and older fail at import statsmodels.api under NumPy 2 with ValueError: numpy.dtype size changed, may indicate binary incompatibility. 0.14.2 is the first release that supports NumPy 2; newer SciPy and pandas 3 then break older 0.14.x in two more ways. Tested below.
1. Reproduce: statsmodels 0.14.1 with NumPy 2
A Python 3.11 venv with statsmodels==0.14.1, then numpy==2.2.6, scipy==1.15.3 and pandas==2.2.3 installed in a second command. Asking for both at once is refused:
error: No solution found when resolving dependencies
cause: Because statsmodels==0.14.1 depends on numpy>=1.18,<2 and you require statsmodels==0.14.1, we can conclude that you require numpy>=1.18,<2.
And because you require numpy==2.2.6, we can conclude that your requirements are unsatisfiable.
b1.py:
import numpy
print("numpy", numpy.__version__)
import statsmodels.api as sm
print("statsmodels", sm.__version__)
x = sm.add_constant(numpy.arange(10.0))
y = 2 * numpy.arange(10.0) + 1
print(sm.OLS(y, x).fit().params.round(3))
Output, exit code 1 (paths shortened to /venv):
numpy 2.2.6
Traceback (most recent call last):
File "b1.py", line 3, in <module>
import statsmodels.api as sm
File "/venv/lib/python3.11/site-packages/statsmodels/api.py", line 125, in <module>
from .graphics import api as graphics
File "/venv/lib/python3.11/site-packages/statsmodels/graphics/api.py", line 9, in <module>
from .regressionplots import (
File "/venv/lib/python3.11/site-packages/statsmodels/graphics/regressionplots.py", line 23, in <module>
from statsmodels.nonparametric.smoothers_lowess import lowess
File "/venv/lib/python3.11/site-packages/statsmodels/nonparametric/smoothers_lowess.py", line 11, in <module>
from ._smoothers_lowess import lowess as _lowess
File "statsmodels/nonparametric/_smoothers_lowess.pyx", line 1, in init statsmodels.nonparametric._smoothers_lowess
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
It fails at import statsmodels.api, in the compiled _smoothers_lowess extension, built against NumPy 1.x. statsmodels 0.14.0 gives the same numpy.dtype size changed error with NumPy 2, and its metadata has no numpy<2 cap, so pip installs NumPy 2 next to it without complaint.
2. Which statsmodels version supports NumPy 2
PyPI metadata: 0.14.0 numpy>=1.18 (uncapped, but broken on NumPy 2); 0.14.1 numpy<2,>=1.18; 0.14.2 numpy>=1.22.3. statsmodels 0.14.2 is the first release that works with NumPy 2; with numpy 2.2.6, scipy 1.15.3 and pandas 2.3.3 it ran b1.py:
numpy 2.2.6
statsmodels 0.14.2
[1. 2.]
3. Fix: pin numpy<2, or upgrade statsmodels
$ pip install "numpy<2"
$ python b1.py
numpy 1.26.4
statsmodels 0.14.1
[1. 2.]
$ pip install -U statsmodels scipy pandas numpy
$ python b1.py
numpy 2.4.6
statsmodels 0.15.0
[1. 2.]
On Python 3.11 the upgrade resolved to statsmodels 0.15.0, NumPy 2.4.6, SciPy 1.17.1 and pandas 3.1.0. Upgrade all four together: a partial upgrade hits the two errors below.
4. ImportError: cannot import name '_lazywhere' from 'scipy._lib._util'
statsmodels 0.14.4 (also 0.14.0 and 0.14.2) with SciPy 1.16.0 or newer. SciPy 1.15.3 imports fine; 1.16.0 fails:
numpy 2.4.6
Traceback (most recent call last):
File "b1.py", line 3, in <module>
import statsmodels.api as sm
File "/venv/lib/python3.11/site-packages/statsmodels/api.py", line 76, in <module>
from . import datasets, distributions, iolib, regression, robust, tools
File "/venv/lib/python3.11/site-packages/statsmodels/distributions/__init__.py", line 7, in <module>
from .discrete import (
File "/venv/lib/python3.11/site-packages/statsmodels/distributions/discrete.py", line 5, in <module>
from scipy._lib._util import _lazywhere
ImportError: cannot import name '_lazywhere' from 'scipy._lib._util' (/venv/lib/python3.11/site-packages/scipy/_lib/_util.py)
_lazywhere was a private SciPy helper. statsmodels 0.14.5 ran b1.py with SciPy 1.17.1 (and pandas 2.3.3). Fix: pip install -U statsmodels, or keep the old statsmodels and pin SciPy:
$ pip install "scipy<1.16" "pandas<3"
$ python b1.py
numpy 2.4.6
statsmodels 0.14.4
[1. 2.]
5. TypeError: deprecate_kwarg() missing 1 required positional argument: 'new_arg_name'
statsmodels 0.14.5 (and 0.14.4) with pandas 3.1.0, NumPy 2.4.6, SciPy 1.17.1:
numpy 2.4.6
Traceback (most recent call last):
File "b1.py", line 3, in <module>
import statsmodels.api as sm
File "/venv/lib/python3.11/site-packages/statsmodels/api.py", line 123, in <module>
from .graphics import api as graphics
File "/venv/lib/python3.11/site-packages/statsmodels/graphics/api.py", line 1, in <module>
from . import tsaplots as tsa
File "/venv/lib/python3.11/site-packages/statsmodels/graphics/tsaplots.py", line 11, in <module>
from statsmodels.tsa.stattools import acf, pacf, ccf
File "/venv/lib/python3.11/site-packages/statsmodels/tsa/stattools.py", line 395, in <module>
@deprecate_kwarg("unbiased", "adjusted")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: deprecate_kwarg() missing 1 required positional argument: 'new_arg_name'
The same 0.14.5 install ran b1.py after pip install "pandas<3" (pandas 2.3.3), and statsmodels 0.15.0 runs with pandas 3.1.0 (section 3). Fix: pip install -U statsmodels, or pip install "pandas<3". More pandas 3 changes: pandas 3 breaking changes.
Restart any Jupyter kernel after changing versions. Same NumPy 2 problem elsewhere: SciPy, scikit-learn, Matplotlib, PyArrow. All changes: NumPy 2 breaking changes.
Frequently asked questions
Which statsmodels version supports NumPy 2?
statsmodels 0.14.2: it dropped the numpy<2 cap and ran with numpy 2.2.6 in this test. 0.14.0 and 0.14.1 failed with numpy.dtype size changed.
How do I fix cannot import name '_lazywhere' from 'scipy._lib._util'?
Upgrade statsmodels (0.14.5 worked with SciPy 1.17.1), or pin scipy<1.16 for older statsmodels.
What causes deprecate_kwarg() missing 1 required positional argument 'new_arg_name'?
statsmodels 0.14.x with pandas 3. Upgrade to statsmodels 0.15.0 or pin pandas<3.
Written with AI assistance. Measured on 2026-10-24 on Linux with Python 3.11.17: statsmodels 0.14.0, 0.14.1, 0.14.2, 0.14.4, 0.14.5 and 0.15.0 against numpy 1.26.4/2.2.6/2.4.6, scipy 1.15.3/1.16.0/1.17.1 and pandas 2.2.3/2.3.3/3.1.0. The script ran verbatim and output was pasted unedited (paths shortened). Version pins read from PyPI metadata the same day. PlainTables is our extension; statsmodels, NumPy, SciPy and pandas are free.