【问题标题】:Jupyter Notebook crashes every time there is an error每次出现错误时,Jupyter Notebook 都会崩溃
【发布时间】:2022-01-24 13:29:45
【问题描述】:

每次执行错误时,Jupyter Notebook 都会崩溃,但不会在笔记本上显示错误,而是在 Jupyter 提示符上显示。

它迫使我每次都重新启动笔记本并执行所有单元格。

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_'

【问题讨论】:

    标签: django jupyter-notebook django-shell


    【解决方案1】:

    修补程序

    这并不能解决问题,但它为问题提供了临时解决方案。 它允许在不崩溃笔记本的情况下显示错误/执行错误

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

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2018-02-24
    • 1970-01-01
    • 2015-12-29
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-21
    • 2017-03-31
    相关资源
    最近更新 更多