Repository navigation
Description
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
Activity
MrMino commentedon Mar 20, 2022
Which version of IPython is this? There were at least 4 releases in 8.. series, IIRC some of them aimed at patching similar issues.
2sn commentedon Mar 20, 2022
IPython 8.1.1- the latest I can get on pip.2sn commentedon Mar 20, 2022
The previous 8-series versions had the same issue.
MrMino commentedon Mar 20, 2022
Do you have a minimal set of steps to reproduce this? If you're using autoreload it might be specific to the code you are reloading.
2sn commentedon Mar 20, 2022
Unfortunately all I can show is the tracebacks. I seems to be related to autoreload that involves data current objects. Usually of rather complex data objects,
2sn commentedon Mar 20, 2022
another example:
Then Ipython terminates and I have to start over again.
2sn commentedon Mar 20, 2022
It seems to be related to
render_traceback. I wonder whether the new new util the Ipython 8.x uses to render output should be rolled back to the previous - working - version. What is currently being used does not yet seem ready for prime time.Carreau commentedon Mar 21, 2022
which version of
executingandstack_data?2sn commentedon Mar 21, 2022
I use the current versions from pip
2sn commentedon Mar 21, 2022
the last error always seems to come from
executing- maybe this needs to be replaced by a properly debugged package?Carreau commentedon Mar 21, 2022
2sn commentedon Mar 22, 2022
Hmm, it seems it was not successful then.
I see many dozens of these per day:
Should I switch to an earlier version? Can it be disabled?
2sn commentedon Mar 22, 2022
I installed Version 0.7.0, still fails.
Maybe to replace the
raisestatement by apass?2sn commentedon Mar 22, 2022
that did not help, now I end up with
brandondube commentedon Mar 25, 2022
22 remaining items
pestrela commentedon Jan 22, 2023
@alexmojaki I want to report that this bugfix fixed my significant autoreload problems. Many thanks!
The pattern was this infamous message:
PS: Please also note this trivial autoreload bugfix for python3 required kwargs: #14145
quswadress commentedon Apr 20, 2023
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 havingexecutingversion1.2.0the bug remains.alexmojaki commentedon Apr 20, 2023
The
@enhance_methodreproduction is a bit too contrived. Does the error still manifest in a practical setting?quswadress commentedon Apr 20, 2023
Um, yeah? It was because I encountered this error in my notebook that I googled this issue.
However, I have already restarted linux and this error has disappeared 😆 so I cannot send a screenshot of this error.
So I think it's rare enough to fix it)
rawlins commentedon Oct 1, 2023
Just encountered this in fairly current IPython, this env has:
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.)
6502 commentedon Nov 3, 2023
Just bumped into the same error using IPython directly from terminal and pressing ctrl-c to stop a loop printing solutions to an equation. 8/10 the loop terminates normally (KeyboardInterrupt), but 2/10 I get the following instead:
I am using Arch ...
janhavi-sathe commentedon Nov 13, 2023
Adding a comment here as I also got this error. Restarting the kernel seems to be the only way out.
h-sellak commentedon Jan 1, 2024
Faced the same issue with:
import IPython, executing
IPython.version, executing.version
('8.15.0', '0.8.3')
I still don't understand the source of the problem though. Will update this comment as I find new evidence.
alexmojaki commentedon Jan 1, 2024
That's not the latest version of executing. I think conda or something weirdly uses an old version of executing when installing IPython.
Prevent crash on StackData NotOneValueFound.
Prevent crash on StackData NotOneValueFound. (#14286)
gsmecher commentedon Aug 21, 2024
@alexmojaki, I am also still bumping into this issue. Perhaps this is a less contrived use-case than the reproducers provided by @quswadress or @mlucool.
The workaround in current IPython code (9699b3e) isn't really satisfying because it suppresses the traceback to avoid the issue.
Reproducer:
Depending on your ipython version, you'll get either a double exception (NotOneValueFound) or an abbreviated traceback due to the workaround linked above.
The awaitless extension uses an AST transformer, so it is mangling source code - whether this is a valid use case is a judgement call I'll leave up to you. (Disclaimer: it's my extension.)
Work around backtrace double-exceptions
user202729 commentedon Nov 19, 2024
I come across this issue while working with Cython in SageMath.
Reproduction steps:
Create
a.pyxCreate
setup.pypython setup.py build_ext --inplaceecho > a.pyx(make it 0 lines long)ipythonfrom a import ff()alexmojaki commentedon Nov 19, 2024
If the source code doesn't match the executed code, you can expect something to go wrong. If it didn't crash, it would silently show an incorrect and potentially misleading traceback. I'm sure that's often the case when you do the kind of thing above but the line of the exception doesn't happen to be blank. That's not really solvable.