Running
# Some more magic so that the notebook will reload external python modules;
# see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython
%load_ext autoreload
%autoreload 2
with Python 3.12 results in the following error:
ModuleNotFoundError Traceback (most recent call last)
[/tmp/ipython-input-3121226903.py](https://localhost:8080/#) in <cell line: 0>()
15 # Some more magic so that the notebook will reload external python modules;
16 # see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython
---> 17 get_ipython().run_line_magic('load_ext', 'autoreload')
18 get_ipython().run_line_magic('autoreload', '2')
...
[/usr/local/lib/python3.12/dist-packages/IPython/extensions/autoreload.py](https://localhost:8080/#) in <module>
119 from importlib import import_module
120 from importlib.util import source_from_cache
--> 121 from imp import reload
122
123 #------------------------------------------------------------------------------
ModuleNotFoundError: No module named 'imp'
This seems to be because imp was deprecated in 3.12 but available in earlier major versions of Python