ipython: ipython 8+ python crash on exception

Since version 8 in Ipython I frequently - very frequently - get IPython crashes (termination) of the kind below.

I think the specific situation is that I edit code, I use autoreload(3), there is a bug, but when IPython tries traceback it crashes and terminates. Since a main point of using IPython is the auto-reload, this makes it almost unusable for development compared to Version 7.x.x. (Certainly distracting enough to spend the time to finally post it here.)

I have seen there is a few other bugs of that kind reported, but I was not sure which would be similar enough to any of them, hence I post this separately. My apologies for any duplications.

I am not sure whether the error is strictly reproducible as it happens in situations when code is edited.

I use Python 3.10.2 built from source on Linux (Fedora 34).

I am using pylab mode which loads matplotlib, I am not sure whether their event loop may interfere with IPython. Just a thought.

In [15]: m.plot1()
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1979, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'NotOneValueFound' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1981, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 871, in structured_traceback
    formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 804, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 723, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 628, in executing_piece
    return only(
  File "/home/alex/Python/lib/python3.10/site-packages/executing/executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

Original exception was:
Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3361, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-15-0de954ff7b19>", line 1, in <cell line: 1>
  File "/home/alex/python/source/multistar/base.py", line 586, in plot1
    rr = norm(self.y[self.y_rad])
AttributeError: 'Direct' object has no attribute 'y_rad'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1979, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'AttributeError' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3301, in run_ast_nodes
    if await self.run_code(code, result, async_=asy):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3378, in run_code
    self.showtraceback(running_compiled_code=True)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1981, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 852, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 804, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 723, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 628, in executing_piece
    return only(
  File "/home/alex/Python/lib/python3.10/site-packages/executing/executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1979, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'NotOneValueFound' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 2900, in _run_cell
    return runner(coro)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/async_helpers.py", line 129, in _pseudo_sync_runner
    coro.send(None)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3098, in run_cell_async
    has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3320, in run_ast_nodes
    self.showtraceback()
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1981, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 871, in structured_traceback
    formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 804, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 723, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 628, in executing_piece
    return only(
  File "/home/alex/Python/lib/python3.10/site-packages/executing/executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1979, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'NotOneValueFound' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/Python/bin/ipython3", line 8, in <module>
    sys.exit(start_ipython())
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/__init__.py", line 123, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/home/alex/Python/lib/python3.10/site-packages/traitlets/config/application.py", line 846, in launch_instance
    app.start()
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/terminal/ipapp.py", line 318, in start
    self.shell.mainloop()
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 653, in mainloop
    self.interact()
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 646, in interact
    self.run_cell(code, store_history=True)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 2854, in run_cell
    result = self._run_cell(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 2905, in _run_cell
    self.showtraceback(running_compiled_code=True)
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1981, in showtraceback
    stb = self.InteractiveTB.structured_traceback(etype,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1105, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 999, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 871, in structured_traceback
    formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 804, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/home/alex/Python/lib/python3.10/site-packages/IPython/core/ultratb.py", line 723, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/alex/Python/lib/python3.10/site-packages/stack_data/core.py", line 628, in executing_piece
    return only(
  File "/home/alex/Python/lib/python3.10/site-packages/executing/executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 12
  • Comments: 42 (15 by maintainers)

Commits related to this issue

Most upvoted comments

New fix is released in executing 1.0.0!

Here’s a repro for this. On my system I was able to consistently trigger this type of exception by importlib.reload’ing a module. It seems ipython gets confused when the module changes on disk and the old source location of the error does not align with the new source location. I can imagine that running conda/pip/other package managers while ipython is running may also cause this issue.

I’m running jupyterlab 3.4.3, jupyter-nbclassic 0.3.7, jupyter-notebook 6.4.12, and python 3.10.5 on Arch Linux x86_64.

To reproduce, run these three ipython cells in order:

Cell 1

import importlib
import sys
from pathlib import Path

tmpdir = Path('/tmp/traceback_exc_test')
tmpdir.mkdir(exist_ok=True)
sys.path.append(str(tmpdir))

(tmpdir / 'ipy_err_test_module.py').write_text('print("imported version 1")\ndef crash_and_burn():\n    raise ValueError()')

import ipy_err_test_module
try:
    ipy_err_test_module.crash_and_burn()
except:
    pass

Output:

imported version 1

Cell 2

(tmpdir / 'ipy_err_test_module.py').write_text('print("imported version 2")\n\n\ndef crash_and_burn():\n    raise SystemError()')

importlib.reload(ipy_err_test_module)
ipy_err_test_module.crash_and_burn()

Output:

---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
Input In [2], in <cell line: 4>()
      1 (tmpdir / 'ipy_err_test_module.py').write_text('print("imported version 2")\n\n\ndef crash_and_burn():\n    raise SystemError()')
      3 importlib.reload(ipy_err_test_module)
----> 4 ipy_err_test_module.crash_and_burn()

File /tmp/traceback_exc_test/ipy_err_test_module.py:5, in crash_and_burn()
      4 def crash_and_burn():
----> 5     raise SystemError()

SystemError: 

Cell 3

(tmpdir / 'ipy_err_test_module.py').write_text('print("imported version 2")\n\n\n\n\n\n\ndef crash_and_burn():\n    raise SystemError()')

importlib.reload(ipy_err_test_module)
ipy_err_test_module.crash_and_burn()

Output:

(tmpdir / 'ipy_err_test_module.py').write_text('print("imported version 2")\n\n\n\n\n\n\ndef crash_and_burn():\n    raise SystemError()')

​

importlib.reload(ipy_err_test_module)

ipy_err_test_module.crash_and_burn()

imported version 2
Unexpected exception formatting exception. Falling back to standard exception

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3398, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "/tmp/ipykernel_5390/429422080.py", line 4, in <cell line: 4>
    ipy_err_test_module.crash_and_burn()
  File "/tmp/traceback_exc_test/ipy_err_test_module.py", line 9, in crash_and_burn
    raise SystemError()
SystemError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1993, in showtraceback
    stb = self.InteractiveTB.structured_traceback(
  File "/usr/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1118, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/usr/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1012, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/usr/lib/python3.10/site-packages/IPython/core/ultratb.py", line 865, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
  File "/usr/lib/python3.10/site-packages/IPython/core/ultratb.py", line 818, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/usr/lib/python3.10/site-packages/IPython/core/ultratb.py", line 736, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/usr/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/usr/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/lib/python3.10/site-packages/stack_data/core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/usr/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/lib/python3.10/site-packages/stack_data/core.py", line 628, in executing_piece
    return only(
  File "/usr/lib/python3.10/site-packages/executing/executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

@alexmojaki A way to catch reloading modules would be to insert a MetaPathFinder at index 0 of sys.meta_path. When any module is reloaded, that finder will get its find_spec method called with the original path of the modules __init__.py as the target argument (which otherwise would be None). Thus, this finder can catch when any module is re-imported and you could use it to just drop all caches when that happens.

IMHO this solution is pretty minimally invasive, as it does not mess around with python’s actual importing machinery.

Here’s a demo:

import importlib
import importlib.abc
import sys

class PrintFinder(importlib.abc.MetaPathFinder):
    def find_spec(fullname, path, target=None):
        if target:
            print('    reloading', fullname, path, target)
            # drop caches here

sys.meta_path.insert(0, PrintFinder)

print('=== Initial import ===')
import requests
print('=== Reload ===')
importlib.reload(requests)

Output:

=== Initial import ===
=== Reload ===
    reloading requests None <module 'requests' from '/usr/lib/python3.10/site-packages/requests/__init__.py'>

Just encountered this in fairly current IPython, this env has:

>>> import IPython, executing
>>> IPython.__version__, executing.__version__
('8.15.0', '1.2.0')

Went away on restart kernel + clear all outputs, sorry to not have any more concrete repro info. (Edit: to clarify, the context was fairly chaotic, was actually debugging repr code for an exception class that in my code is triggered via a magic – so lots of restarting + raising in a non-recoverable sequence. Exactly the sort of scenario where you’d expect a bug like this to pop up if it can, but not helpful for repro.)

Greetings all! I’m just a random developer that ran into this bug and @alexmojaki said that the fix was in executing 1.0.0, however even having executing version 1.2.0 the bug remains.

$ ipython 
Python 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:20:04) [GCC 11.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.11.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import executing
   ...: executing.__version__
Out[1]: '1.2.0'

In [2]: def enhanced_foo(*args, **kwargs):
   ...:     pass
   ...:     pass
   ...:     pass
   ...:     raise ValueError()
   ...: 
   ...: 
   ...: def enhance_method(function):
   ...:     f = enhanced_foo
   ...:     c0 = function.__code__
   ...:     f.__code__ = f.__code__.replace(co_filename=c0.co_filename, co_firstlineno=c0.co_firstlineno)
   ...:     return f
   ...: 
   ...: 
   ...: @enhance_method
   ...: def foo():
   ...:     pass
   ...:     pass
   ...: 
   ...: 
   ...: foo()
Unexpected exception formatting exception. Falling back to standard exception
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3460, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-c6b7ce91db6a>", line 21, in <module>
    foo()
  File "<ipython-input-2-c6b7ce91db6a>", line 19, in enhanced_foo
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 2057, in showtraceback
    stb = self.InteractiveTB.structured_traceback(
  File "/opt/conda/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1288, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/opt/conda/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1177, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/opt/conda/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1030, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
  File "/opt/conda/lib/python3.10/site-packages/IPython/core/ultratb.py", line 960, in format_exception_as_a_whole
    frames.append(self.format_record(record))
  File "/opt/conda/lib/python3.10/site-packages/IPython/core/ultratb.py", line 870, in format_record
    frame_info.lines, Colors, self.has_colors, lvals
  File "/opt/conda/lib/python3.10/site-packages/IPython/core/ultratb.py", line 704, in lines
    return self._sd.lines
  File "/opt/conda/lib/python3.10/site-packages/stack_data/utils.py", line 144, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/opt/conda/lib/python3.10/site-packages/stack_data/core.py", line 734, in lines
    pieces = self.included_pieces
  File "/opt/conda/lib/python3.10/site-packages/stack_data/utils.py", line 144, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/opt/conda/lib/python3.10/site-packages/stack_data/core.py", line 681, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "/opt/conda/lib/python3.10/site-packages/stack_data/utils.py", line 144, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/opt/conda/lib/python3.10/site-packages/stack_data/core.py", line 660, in executing_piece
    return only(
  File "/opt/conda/lib/python3.10/site-packages/executing/executing.py", line 190, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

Thanks for the report @jaymegordo. It’s interesting that you’re still experiencing with the combination of the latest executing and autoreload, which isn’t supposed to happen. That suggests that either there’s another MetaPathFinder getting in the way as @yonatanp feared, or there’s a bug in mine.

In any case, I have a plan for a completely general solution, which wouldn’t rely on a MetaPathFinder and would include situations that don’t involve reloading modules like @ChrisBarker-NOAA repeatedly running files. I should have it done this weekend.

I get the same long stream of errors that end with “executing.executing.NotOneValueFound: Expected one value, found 0” on windows with ipython 8.4.0 (python 3.9.2). I just start ipython, import, edit, re-import and at some point when my script raises an error I get it.