Debugging a module in Pycharm. Breakpoint stops execution but doesn't catch anything.

Hi all,

I'm developing a module in Pycharm and I was wondering how best I could debug my work.

I've set up Pycharm in Run/Debug Configurations to load my module and use my virtual environment as an interpreter. I checked "Run with Python console".

It loads up ipython fine and I can create an instance of my class and run functions against it. While execution seems to stop at the breakpoint I have set in Pycharm, it doesn't catch it and let me step through or do anything else. Execution just stops. If I remove the breakpoint and restart it, it runs through the function fine.

How can I properly catch breakpoints so that I can start debugging?

Thanks.

5 comments
Comment actions Permalink

By "Execution just stops", do you mean that the python process stops? Or is it still being run in the background? 

What happens if you debug your code without using python console, by running the debug configuration?

0
Comment actions Permalink

It just pauses. The Python process is still running. I checked this by placing print statements - print statements before the breakpoint print out but none after do.

If I debug my code by running an actual script that uses imports, then the debugger works fine on breakpoints in my module.

I'm already running the debug configuration, but I set Module name to my module and select checkbox "Run with Python console". Then when I click on the run in debug mode icon on the toolbar, it pops up with an IPython console where I can import classes and run stuff.

If I set it to not use the Python console, I get this output:

pydev debugger: process 5570 is connecting

Connected to pydev debugger (build 183.5912.18)

Process finished with exit code 0

EDIT: I tried it out with a newer version

PyCharm 2019.2 EAP (Community Edition)
Build #PC-192.4205.50, built on May 27, 2019
Runtime version: 11.0.3+12-b248.2 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.1.3-arch1-1-ARCH
GC: ParNew, ConcurrentMarkSweep
Memory: 725M
Cores: 8
Registry:
Non-Bundled Plugins: IdeaVIM

and it is the same. Before I was using CE 2018.3.5.

0
Comment actions Permalink

Try the following:

1. Open Python console

2. Connect the console to debugger:

3. Import your module

4. Place a breakpoint in the code of some function

5. Call the function from the console

6. After the execution is paused, check out the debugger tab, if it's not comes into focus automatically.

0
Comment actions Permalink

That works, thank you!

Another quick question - does the integrated console support recursive search? Ctrl+r doesn't seem to do anything.

If not, is it possible to connect IPython running in a terminal to the debugger instead?

0
Comment actions Permalink

All I can say is that both integrated python console and integrated terminal support search with Ctrl+F. Not sure about "recursive" part. In the editor, Ctrl+R is search and replace by default.

0

Please sign in to leave a comment.