Instructions on how to debug in pycharm - Verified with latest pycharm pro

Hi there, I was attempting use pycharm to debug, and a lot of the stuff on the forums didn’t work.

Here is instructions that worked for me:

  1. Get frappe bench setup and your site up and running on port 8000

  2. Open the frappe project from apps/frappe in pycharm

  3. Open the erpnext project from apps/erpnext, and add to existing project.

  4. Go to file Project dependencies, and make each project dpending on each other
    50

  5. Set up a new python interpreter environment, and choose the existing venv that bench is using

  6. Set up a new configuration under run/debug and set up as appropriate (running on port 8001, since 8000 is still being used by bench), using the interpreter you set up previously

Now start up in debug mode
visit your site:8001
and your breakpoints will be hit in either frappe or erpnext.

Caveats I’ve found so far:
cant debug python rq jobs
socketio doesnt work, since its running on port 8000, but it tries looking for it on port 8001.

Feel free to let me know any feedback.
Thanks

8 Likes

Just to add to this I found the following:

It has a better way to do it by stopping bench serve from running, so that then pycharm could run on port 8000. This would then allow socketio etc to all keep working.

Just put the link in here so that it doesn’t get lost - The wiki on frappe github has some gems.

1 Like

Yes, i can confirm that this works, after trying different suggestion from different links. here is my screenshot, below

1 Like

hi @kingsley, basically I followed @cjpit guide, along with your configuration, running PyCharm 2021.

Tried to break at frappe/frappe/www/login.py, and browser at http://site1.local:8000/login, but it just won’t break anywhere in login.py.

I’m at v13.17, bench at 5.0.0dev. It is a brand new install from bench.

I also tried to break at frappe/frappe/app.py. It won’t break too.

Any idea on how to proceed? Much much thanks in advance.

PS: the above is occurs after I pressed the green Triangle button next to Edit Configuration pulldown menu. When I think of it, I think I should press the green Bug icon instead?

13%20PM

After clicking on the green Bug icon, I get the following, which says module bench_helper is not found.