iPython Magic %debug doesn't work

Answered

In Spyder, I was able to use the %debug magic function to interactively go up the stack trace for the last error thrown. When I try to do the same with the interpreter in PyCharm it tells me " No traceback has been produced, nothing to debug."

Here is code that obviously throws an error:

def f(a):
print a
return asdfas #throw error
def g():
return f(5)

g()

After throwing the error, %debug gives me the following message:

ERROR:root:No traceback has been produced, nothing to debug.

 

0
1 comment
Official comment

Hi! Yes, it's a bug: https://youtrack.jetbrains.com/issue/PY-15215
But in order to catch exceptions in your program, you can use exception breakpoints in PyCharm debugger: https://www.jetbrains.com/help/pycharm/creating-exception-breakpoints.html

Please sign in to leave a comment.