using ipdb to debug python code in one cell (jupyter or Ipython)

后端 未结 4 966
野的像风
野的像风 2020-12-12 11:58

I\'m using jupyter (or Ipython) notebook with firefox, and want to debug some python code in the cell. I am using \'import ipdb; ipdb.set_trace()\' as kind of breakpoint, fo

4条回答
  •  一生所求
    2020-12-12 12:44

    Had this problem also and it seems to be related to versions of jupyter and ipdb.

    Solution is to use this instead of the ipdb library set_trace call:

    from IPython.core.debugger import Tracer
    Tracer()() #this one triggers the debugger
    

    Source: http://devmartin.com/blog/2014/10/trigger-ipdb-within-ipython-notebook/

    Annotated screenshot:

提交回复
热议问题