I've just started using the nice PyCharm community edition IDE, and can't do a simple thing that is part of my usual Python workflow.
I've started an ipython console and I can import my modules and interactively run commands. In PyCharm when I execute a function call, it is executed like it was running in a separate process. The console prompt can be used even before the execution finishes. It is nice but prevents me to do post mortem debugging.
Running ipython in a shell outside PyCharm, when an exception happens, I can run pdb's post mortem feature and investigate the problem:
import pdb;pdb.pm()
I want to do the same in PyCharm: start post mortem debugging when an exception happens while I'm interactively investigating a problem.
Given that you are using PyCharm, why not use the built-in debugger? There is ample documentation on how you can use it to set your own breakpoints, step through your stack, configure the debugger options etc.
Specifically for your use case, if you want to break on exceptions -- you can use Ctrl + Shift + F8 to open the breakpoints configuration screen. You can then check to break on Any exception for Python Exception Breakpoint. This would give you access to the exception and the entire stack (in the Frames section), context, variables etc. when something does happen.
It is possible in IPython to use the %pdb
magic.
Simply use %pdb
on IPython and whenever an error occurs you will be dropped in an ipdb
session with the Post Mortem of the error.
I don't really know if this works in PyCharm.
(I found this answer here some time ago)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With