notebook 中內(nèi)建的pdb
在需要breakpoint的地方插入import pdb; pdb.set_trace()
,運(yùn)行后會(huì)進(jìn)入debugger炫狱,有一個(gè)交互界面。
def test_breakpoint_with_ipdb():
a = 1
import pdb; pdb.set_trace()
b = 2
c = 3
final = a + b + c
return final
test_breakpoint_with_ipdb()
debugger會(huì)在斷點(diǎn)前停下剔猿,
n
執(zhí)行下一行视译,c
執(zhí)行下面所有代碼。h
可以查看所有命令归敬。ipdb
from IPython.core.debugger import set_trace
def test_breakpoint_with_ipdb():
a = 1
set_trace()
b = 2
c = 3
final = a + b + c
return final
test_breakpoint_with_ipdb()
如果遇到報(bào)錯(cuò)更新一下ipython:
conda update ipython
conda update ipykernel