python - ipython 中的调试器不工作

标签 python debugging ipython

我尝试在 Windows 7 上安装的 python 2.7.9 上使用 ipython 3.1 中的调试器。

这是一个示例脚本:

def works_fine():
    a = 5
    b = 6
    assert(a + b == 11)

def throws_an_exception():
    a = 5
    b = 6
    assert(a + b == 10)

def calling_things():
    works_fine()
    throws_an_exception()

calling_things()

我使用 %debug 进入代码。

我和你一起上

然后我在第 12 行添加一个断点 b 12

我按c

然后调试器不再运行 continue,而是打印出“ipdb> c”而不是 continue.. 我应该如何解决这个问题?

> <ipython-input-7-c95b844c9880>(9)throws_an_exception()
      8     b = 6
----> 9     assert(a + b == 10)
     10 

ipdb> u
> <ipython-input-7-c95b844c9880>(13)calling_things() 2    12     works_fine()
---> 13     throws_an_exception()
     14 

ipdb> b 12 Breakpoint 3 at <ipython-input-7-c95b844c9880>:12
ipdb> c

最佳答案

我明白了。我需要将代码放入文件中并运行 -d xxxx.py。此后c继续工作正常!

run -d ch03/ipython_bug.py

关于python - ipython 中的调试器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30432412/

相关文章:

python - NSUserNotificationCenter.defaultUserNotificationCenter() 使用 PyInstaller 返回 None

java - Java 热交换的局限性

debugging - 使用用户模式转储确定 WinDbg 中线程的创建时间

python - 为什么 "pip3 --help"失败?

python - 是否可以设置 ipython 来标记完整的函数参数参数

python - 创建带有类别的时间序列的巧妙方法

python - 在 Python 中执行带有特殊字符的 Linux 命令

python - 为什么很多例子在 Matplotlib/pyplot/python 中使用 `fig, ax = plt.subplots()`

java - 无法从 ListArray 中获取随机元素

python - 等同于 IPython 的 PATH 变量?