You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently Python 3.11 isn't fully supported in statsmodels yet, including testing in CI and publishing wheels to PyPI.
Python 3.11 is now in beta and feature stable. By testing Python 3.11 in CI we can catch errors and bugs before Python 3.11 will become stable, and packages dependent on statsmodels can start working on their Python 3.11 support. statsmodels is one of the most used packages and a package on which many other packages depend, so early support will help speed up Python 3.11 adoption.
Python 3.11 is expected to be released as stable in October 2022, with many new features including:
PEP 657 -- Include Fine-Grained Error Locations in Tracebacks
The Faster Cpython Project is already yielding some exciting results. Python 3.11 is up to 10-60% faster than Python 3.10. On average, we measured a 1.22x speedup on the standard benchmark suite. See Faster CPython for details.
Among others, Numpy and SciPy and can now be built on their main branches with Python 3.11, and Pandas is also working on their 3.11 support.
Reacted by David Gilbertson, Jarrod Millman, Christian Clauss, Ruaridh Williamson and Matthew Lloyd
Python 3.11 support will likely only be available once NumPy, SciPy, Cython and Pandas have wheels available for 3.11, which won't happen until their first release after 3.11.0.
We could start with testing in CI and fixing bugs that come up earlier than that, right?
NumPy, SciPy and Cython built are now building and testing fine on Python 3.11, as for Pandas we can track their progress in pandas-dev/pandas#46680.
statsmodels is a low level dependency for many projects, so the sooner Python 3.11 is supported the sooner those other project can work on their support.
We are already testing against pre-releases of NumPy, Scipy and pandas. We don't directly use the Python C API afaik, and so as long as Cython is generating correct C code, we won't have any issues. I don't think it worth the effort. This said, if you want to setup a CI using pre-prelease wheels for NumPy and Python 3.11 beta, I would accept the PR.
In Fedora we are rebuilding all packages with Python 3.11. statsmodels fails with:
statsmodels/tsa/_innovations.c: In function ‘__Pyx_PyErr_GetTopmostException’:
statsmodels/tsa/_innovations.c:20057:21: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
20057 | while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
| ^~
statsmodels/tsa/_innovations.c:20057:51: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
20057 | while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
| ^~
statsmodels/tsa/_innovations.c: In function ‘__Pyx__ExceptionSave’:
statsmodels/tsa/_innovations.c:20071:21: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
20071 | *type = exc_info->exc_type;
| ^~
statsmodels/tsa/_innovations.c:20073:19: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
20073 | *tb = exc_info->exc_traceback;
| ^~
statsmodels/tsa/_innovations.c: In function ‘__Pyx__ExceptionReset’:
statsmodels/tsa/_innovations.c:20087:24: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
20087 | tmp_type = exc_info->exc_type;
| ^~
statsmodels/tsa/_innovations.c:20089:22: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
20089 | tmp_tb = exc_info->exc_traceback;
| ^~
statsmodels/tsa/_innovations.c:20090:13: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
20090 | exc_info->exc_type = type;
| ^~
statsmodels/tsa/_innovations.c:20092:13: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
20092 | exc_info->exc_traceback = tb;
| ^~
statsmodels/tsa/_innovations.c: In function ‘__Pyx__GetException’:
statsmodels/tsa/_innovations.c:20149:28: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
20149 | tmp_type = exc_info->exc_type;
| ^~
statsmodels/tsa/_innovations.c:20151:26: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
20151 | tmp_tb = exc_info->exc_traceback;
| ^~
statsmodels/tsa/_innovations.c:20152:17: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
20152 | exc_info->exc_type = local_type;
| ^~
statsmodels/tsa/_innovations.c:20154:17: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
20154 | exc_info->exc_traceback = local_tb;
| ^~
statsmodels/tsa/_innovations.c: In function ‘__Pyx__ExceptionSwap’:
statsmodels/tsa/_innovations.c:20187:24: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
20187 | tmp_type = exc_info->exc_type;
| ^~
statsmodels/tsa/_innovations.c:20189:22: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
20189 | tmp_tb = exc_info->exc_traceback;
| ^~
statsmodels/tsa/_innovations.c:20190:13: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_type’
20190 | exc_info->exc_type = *type;
| ^~
statsmodels/tsa/_innovations.c:20192:13: error: ‘_PyErr_StackItem’ {aka ‘struct _err_stackitem’} has no member named ‘exc_traceback’
20192 | exc_info->exc_traceback = *tb;
| ^~
statsmodels/tsa/_innovations.c: In function ‘__Pyx_AddTraceback’:
statsmodels/tsa/_innovations.c:465:62: error: invalid use of incomplete typedef ‘PyFrameObject’ {aka ‘struct _frame’}
465 | #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
| ^~
statsmodels/tsa/_innovations.c:20798:5: note: in expansion of macro ‘__Pyx_PyFrame_SetLineNumber’
20798 | __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
The interpreter state’s representation of handled exceptions (a.k.a exc_info, or _PyErr_StackItem) now has only the exc_value field, exc_type and exc_traceback have been removed as their values can be derived from exc_value.
Thanks for getting back! I found an abandoned PR over at the Cython repo that looked a lot like the error we're experiencing, so I asked if it could be the same issue.
Edit: It could be that's already fixed in the master branch. Testing Cython 3.0.0a11 now, see this Azure CI run.
If I try to install pip install statmodels with Python 3.11 I get the same error. However the failing file (_innovations.c, and also _qn.c) starts with
/* Generated by Cython 0.29.25 */
which I believe predates the fix. All the other C files look to be generated by Cython 0.29.32. So I don't think this is a Cython bug
@bashtage What do you have in mind for the statsmodels 0.14 release? Is there some timeline or are there some features you want to get in? Can we release it relatively soon? What steps are needed for that?
Backporting a year of changes to 0.13.x is going to be a major effort, so maybe releasing 0.14 is just easier. 0.13.0 is now over a year old so a new release to get all improvements and features out might be a good idea anyway!
I need maybe 2 weeks of work for 0.14.
There are at most a few smaller PRs that can still go in.
I still need more API work on my new features that are in 0.14/main.
The problem is that I have been quite distracted and have not spend enough time on statsmodels 0.14.
How about 0.14rc1 in around two weeks?
(That would put enough pressure on me to finish the API decisions and cleanup.)
I lost the pressure after the 0.13 releases.
(and then I get sometimes more interested in a novel than doing statsmodels maintenance, I'm not getting any money for it anyway)
I need at most a few more days, only one PR that I really would like to get in (tweedie), plus minor issues that I can still find.
Activity
bashtage commentedon May 22, 2022
Python 3.11 support will likely only be available once NumPy, SciPy, Cython and Pandas have wheels available for 3.11, which won't happen until their first release after 3.11.0.
EwoutH commentedon May 23, 2022
We could start with testing in CI and fixing bugs that come up earlier than that, right?
NumPy, SciPy and Cython built are now building and testing fine on Python 3.11, as for Pandas we can track their progress in pandas-dev/pandas#46680.
statsmodels is a low level dependency for many projects, so the sooner Python 3.11 is supported the sooner those other project can work on their support.
bashtage commentedon May 23, 2022
We are already testing against pre-releases of NumPy, Scipy and pandas. We don't directly use the Python C API afaik, and so as long as Cython is generating correct C code, we won't have any issues. I don't think it worth the effort. This said, if you want to setup a CI using pre-prelease wheels for NumPy and Python 3.11 beta, I would accept the PR.
hrnciar commentedon Jun 29, 2022
In Fedora we are rebuilding all packages with Python 3.11. statsmodels fails with:
See https://docs.python.org/3.11/whatsnew/3.11.html#other-cpython-implementation-changes
For a full log see: https://kojipkgs.fedoraproject.org//work/tasks/8082/88568082/build.log
bashtage commentedon Jun 29, 2022
Needs upstream fix in Cython.
hrnciar commentedon Jun 29, 2022
I've managed to build it. Cython is fixed, but sources need to be regenerated.
EwoutH commentedon Oct 5, 2022
We're a far months further, so here a quick update on the ecosystem!
Python 3.11 is now ABI stable with the release candidate series, which means wheels can be uploaded to PyPI!
We're quite far now:
This is in since Cython 0.29.29!
jarrodmillman commentedon Oct 9, 2022
SciPy Python 3.11 wheels are now available: https://pypi.org/project/scipy/1.9.2/
EwoutH commentedon Oct 9, 2022
It looks like currently an error building 'statsmodels.tsa._innovations' extension appears:
Error log building Statsmodels with Python 3.11 on Ubuntu:
@bashtage Would you know how to resolve this issue?
EwoutH commentedon Oct 9, 2022
I also opened an draft PR which tests Python 3.11 on the Azure pipelines CI, so that all errors can be detected there. See the first run here.
Edit: Current CI failures and errors on Ubuntu
bashtage commentedon Oct 9, 2022
I would report the compilation issue to Cython, since this works fine on Python 3.8-3.10.
bashtage commentedon Oct 9, 2022
All of the referenced code is the type either provided by Python or Cython.
EwoutH commentedon Oct 9, 2022
Thanks for getting back! I found an abandoned PR over at the Cython repo that looked a lot like the error we're experiencing, so I asked if it could be the same issue.
Edit: It could be that's already fixed in the master branch. Testing Cython 3.0.0a11 now, see this Azure CI run.
da-woods commentedon Oct 9, 2022
@EwoutH all the code that's giving you errors should be disabled by https://github.com/cython/cython/blob/f2e8b2f3dca7436630b1b4a4d42305adcf173ece/Cython/Utility/ModuleSetupCode.c#L257-L260 so I'm a bit puzzled what's going on.
da-woods commentedon Oct 9, 2022
If I try to install pip install statmodels with Python 3.11 I get the same error. However the failing file (
_innovations.c, and also_qn.c) starts withwhich I believe predates the fix. All the other C files look to be generated by Cython 0.29.32. So I don't think this is a Cython bug
9 remaining items
EwoutH commentedon Oct 26, 2022
If you want to go the backport route, I started a draft PR with backports here:
EwoutH commentedon Oct 27, 2022
@bashtage What do you have in mind for the statsmodels 0.14 release? Is there some timeline or are there some features you want to get in? Can we release it relatively soon? What steps are needed for that?
Backporting a year of changes to 0.13.x is going to be a major effort, so maybe releasing 0.14 is just easier. 0.13.0 is now over a year old so a new release to get all improvements and features out might be a good idea anyway!
josef-pkt commentedon Oct 27, 2022
I need maybe 2 weeks of work for 0.14.
There are at most a few smaller PRs that can still go in.
I still need more API work on my new features that are in 0.14/main.
The problem is that I have been quite distracted and have not spend enough time on statsmodels 0.14.
How about 0.14rc1 in around two weeks?
(That would put enough pressure on me to finish the API decisions and cleanup.)
EwoutH commentedon Oct 27, 2022
If that’s a workable timeframe, sounds good! Keep us in the loop.
bashtage commentedon Nov 1, 2022
Wheels for 3.11 are out now for statsmodels 0.13.3.
https://pypi.org/project/statsmodels/#files
benz0li commentedon Nov 1, 2022
Thank you @bashtage
scipy: Install statsmodels from wheel again
EwoutH commentedon Nov 1, 2022
Awesome, thank you a lot!
scipy: Install statsmodels from wheel again
EwoutH commentedon Nov 18, 2022
I was curious how it's going! Any difficult decisions left?
josef-pkt commentedon Dec 1, 2022
I lost the pressure after the 0.13 releases.
(and then I get sometimes more interested in a novel than doing statsmodels maintenance, I'm not getting any money for it anyway)
I need at most a few more days, only one PR that I really would like to get in (tweedie), plus minor issues that I can still find.
EwoutH commentedon Dec 6, 2022
I understand, volunteer maintenance is hard work.
I see the tweede distribution is in, that’s great!
You can also tag a release candidate as pre-release and let the community help test and find final bugs before the stable release.
If you get to it at some point, it would be hugely appreciated, otherwise it’s also perfectly fine.
EwoutH commentedon Jun 14, 2023
Python 3.12 is now in beta, so I opened a new tracking issue for it: #8914