Error with Autoreload magic since python3.12

I’ve been using this cell magic in my projects before with python3.10
%load_ext autoreload
%autoreload 2

But under python 3.12, when I try to execute any cell afterwards I get:

Error in callback <bound method AutoreloadMagics.pre_run_cell of <IPython.extensions.autoreload.AutoreloadMagics object at 0x7fbb28809580>> (for pre_run_cell):
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: AutoreloadMagics.pre_run_cell() takes 1 positional argument but 2 were given

It would take some more information to determine what is causing the issue.

If this is from an upgraded environment with a bunch of extensions, it’s possible there are dangling old versions that are calling the autoreload machinery directly

For reference, I cannot reproduce this at the command line on a linux-64 system from a clean mamba env pulling packages from conda-forge env with ipython 8.16.1 and python 3.12.0. Adding notebook 7.0.5 also does demonstrate the condition in a browser setting.

2 Likes

Related issue: Using autoreload magic fails with the latest version · Issue #14230 · ipython/ipython · GitHub

2 Likes