Skip to content

9.x autoreload fix #14807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged

9.x autoreload fix #14807

merged 1 commit into from
Mar 3, 2025

Conversation

iloveitaly
Copy link
Contributor

This fixes the following error when attempting to use autoreload in 9.x

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'

@Carreau
Copy link
Member

Carreau commented Mar 3, 2025

That is super weird as I can't trigger it locally, and I can't see why this was not caught by test. But is that fixes it for you...

@Carreau Carreau merged commit d627d00 into ipython:main Mar 3, 2025
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants