&quot'当出现错误时直接输入调试。当我在单元格上运行它时,Spyder中的消息无效

发布于 2025-02-07 12:39:03 字数 802 浏览 2 评论 0原文

我对Spyder中的调试模式有疑问: 在 下,工具 - >偏好 - >运行 我检查了“出现错误时直接输入调试”。当我运行整个脚本时,这很好。例如:

def divide_by(a):
    c=a-2
    return 3/c

divide_by(2)

由于零除法,Spyder引发了错误并跳到调试模式

****************************************
Entering post mortem debugging...
****************************************
> /home/test.py(3)divide_by()
      1 def divide_by(a):
      2     c=a-2
----> 3     return 3/c
      4 
      5 

IPdb[1]:

,但是我将脚本分开为单元格(使用#%%) 例如:

def divide_by(a):
    c=a-2
    return 3/c

#%%
divide_by(2)

当我仅执行最后一个单元格时(仅表示此行:divide_by(2)通过按“运行当前单元格”按钮)时,Spyder会丢弃错误,因为该划分为零,但是它不会跳到调试模式。

是否有可能“直接在出现错误时直接输入调试” - Spyder中的功能在仅一个单元格而不是执行整个脚本时也起作用?

非常感谢您的建议!

I have a question regarding the debugging mode in Spyder:
Under Tools -> preferences -> Run I checked "Directly enter debugging when error appears". This works pretty well when I run the whole script. For example:

def divide_by(a):
    c=a-2
    return 3/c

divide_by(2)

Because of division by zero, Spyder throws an error and jumps to debugging mode

****************************************
Entering post mortem debugging...
****************************************
> /home/test.py(3)divide_by()
      1 def divide_by(a):
      2     c=a-2
----> 3     return 3/c
      4 
      5 

IPdb[1]:

However, I separated my script into cells (using #%%)
For example:

def divide_by(a):
    c=a-2
    return 3/c

#%%
divide_by(2)

When I only execute the last cell (means only this line: divide_by(2) by pressing the "run current cell" button), Spyder is throwing an error because of the division by zero, but it doesn't jump to debugging mode.

Is there any possibility that the "Directly enter debugging when error appears"- functionality in Spyder also works when only a cell and not the whole script is executed?

Many thanks for any suggestions!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文