1

I trying to use the debugger in ipython 3.1 on my python 2.7.9 installation on Windows 7.

Here is an example script:

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()

I step into the code with %debug.

I go up with u

Then I add a breakpoint at line 12 with b 12

I press c

Then instead of the debugger runs continue it prints out "ipdb> c" instead of continue.. How should I solve this?

> <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
2
  • How do you load the code into ipython? Commented May 25, 2015 at 6:37
  • I load it like this: on the first line inside the notebook: 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() Commented May 25, 2015 at 6:41

1 Answer 1

2

I figured it out. I need to put the code in a file and run -d xxxx.py. After this the continue works fine!

run -d ch03/ipython_bug.py
Sign up to request clarification or add additional context in comments.

1 Comment

After an exception, %debug puts you in a post-mortem debugger - this lets you walk up and down the stack to investigate what was going on when the exception hit, but you can't continue or step through the code, because the exception has already stopped execution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.