Debugging a python script in pycharm

Hi,

I have a python script that I would like to debug step by step. I managed to attach Pycharm’s remote debugger to Slicer using these instructions, however, I cannot run the python script in the Slicer GUI’s python console in debugging mode. The only way I have managed to run the script in debugging mode is by creating a custom module and add my code to the onApply() function of the module and press the Apply button. Is there a simpler way to debug python scripts?

The debugger needs a file. So, copying your code snippet into a module is a good approach.

If you work with a code snippet (not saved in file) then you don’t need a debugger, as you can run the code step-by-step anyway.

1 Like