9.x autoreload fix by iloveitaly · Pull Request #14807 · ipython/ipython

In [1]: %load_ext autoreload
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File ~/Projects/python/python-starter-template/.venv/lib/python3.13/site-packages/IPython/core/extensions.py:62, in ExtensionManager.load_extension(self, module_str)
     61 try:
---> 62     return self._load_extension(module_str)
     63 except ModuleNotFoundError:

File ~/Projects/python/python-starter-template/.venv/lib/python3.13/site-packages/IPython/core/extensions.py:77, in ExtensionManager._load_extension(self, module_str)
     76 if module_str not in sys.modules:
---> 77     mod = import_module(module_str)
     78 mod = sys.modules[module_str]

File ~/.local/share/mise/installs/python/3.13.2/lib/python3.13/importlib/__init__.py:88, in import_module(name, package)
     87         level += 1
---> 88 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1324, in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'autoreload'

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 get_ipython().run_line_magic('load_ext', 'autoreload')

File ~/Projects/python/python-starter-template/.venv/lib/python3.13/site-packages/IPython/core/interactiveshell.py:2478, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
   2476     kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2477 with self.builtin_trap:
-> 2478     result = fn(*args, **kwargs)
   2480 # The code below prevents the output from being displayed
   2481 # when using magics with decorator @output_can_be_silenced
   2482 # when the last Python token in the expression is a ';'.
   2483 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File ~/Projects/python/python-starter-template/.venv/lib/python3.13/site-packages/IPython/core/magics/extension.py:33, in ExtensionMagics.load_ext(self, module_str)
     31 if not module_str:
     32     raise UsageError('Missing module name.')
---> 33 res = self.shell.extension_manager.load_extension(module_str)
     35 if res == 'already loaded':
     36     print("The %s extension is already loaded. To reload it, use:" % module_str)

File ~/Projects/python/python-starter-template/.venv/lib/python3.13/site-packages/IPython/core/extensions.py:66, in ExtensionManager.load_extension(self, module_str)
     64 if module_str in BUILTINS_EXTS:
     65     BUILTINS_EXTS[module_str] = True
---> 66     return self._load_extension("IPython.extensions." + module_str)
     67 raise

File ~/Projects/python/python-starter-template/.venv/lib/python3.13/site-packages/IPython/core/extensions.py:77, in ExtensionManager._load_extension(self, module_str)
     75 with self.shell.builtin_trap:
     76     if module_str not in sys.modules:
---> 77         mod = import_module(module_str)
     78     mod = sys.modules[module_str]
     79     if self._call_load_ipython_extension(mod):

File ~/.local/share/mise/installs/python/3.13.2/lib/python3.13/importlib/__init__.py:88, in import_module(name, package)
     86             break
     87         level += 1
---> 88 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1331, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:935, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:1026, in exec_module(self, module)

File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)

File ~/Projects/python/python-starter-template/.venv/lib/python3.13/site-packages/IPython/extensions/autoreload.py:110
    108 from IPython.core import magic_arguments
    109 from IPython.core.magic import Magics, magics_class, line_magic
--> 110 from IPython.extensions.deduperreload.deduperreload import DeduperReloader
    112 __skip_doctest__ = True
    114 # -----------------------------------------------------------------------------
    115 #  Copyright (C) 2000 Thomas Heller
    116 #  Copyright (C) 2008 Pauli Virtanen <pav@iki.fi>
   (...)    127 # Imports
    128 # -----------------------------------------------------------------------------

ModuleNotFoundError: No module named 'IPython.extensions.deduperreload'