Jupyter Notebook crashes every time there is an error

315 views Asked by At

Every time there is an execution error, the Jupyter Notebook crashes without showing the error on the notebook, but showing it on the Jupyter prompt.

It forces me to restart the notebook and execute all the cells each time.

Screenshot of the Notebook freezing when writing an error

[IPKernelApp] ERROR | Exception in message handler:

Traceback (most recent call last):
  File "/Users/<username>/.pyenv/versions/<venv-name>/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3251, in run_code
   exec(code_obj, self.user_global_ns, self.user_ns)
  File "/var/folders/2n/9hgs5nvd6p35c_rzn95txrph00xv/T/ipykernel_7095/881478447.py", line 1, in <module>
   1+"letters"
TypeError: unsupported operand type(s) for +: 'int' and 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/<username>/.pyenv/versions/<venv-name>/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 1934, in showtraceback
   stb = value._render_traceback_()
AttributeError: 'TypeError' object has no attribute '_render_traceback_'
1

There are 1 answers

1
Ibrahim Chiheb On

Hotfix

This doesn't solve the problem, but it provides temporary fix for the problem. It allows to show the bug/execution error without crashing the notebook

import traceback
try:
   1+"letters"
except:
   traceback.print_exc()