DEBUGGING frappe erpnext custom development with PyCharm or any tool

Can anyone please share experiences for a successful debugging setup on Ubuntu 18.4.03, python3, mariadb environment with version-12?

2 Likes

It is not clear enough and simply does not work. Was anyone in the history able to apply this as it is written and get debugging going?

Maybe be clear with what you did or tried that did not work, then folks in the know can respond to help you?

I am using Visual Code remote debugging.

Can you please explain how? I have a develop system installed with Easy Install on Ubuntu 18. It is a vanilla setup now. No custom apps installed. the bench command is under ~/bench

I use eclipse as my IDE, and installed the PyDev plugin. I started the debug server, and used remote debugging, and was able to break step through code and have full access to the debug tools.

I had to add code to enable the debug.


Honoring @clarkej … I’ve been able to successfully configure PyCharm to break and debug the developments… Please find attached the configuration for version-14 on an Ubuntu 22.04LTS

Don’t forget to modify your Procfile ! Comment out the line with web: bench serve --port 8000

2 Likes

@Tufan_Kaynak2 solution is working fine. Just do not forget to add --noreload and --nothreading to the params. Also, add semicolon after the env variables.
Remember to:

  1. Remove/comment out bench serve statement from Procfile
  2. Open only Frappe folder as the project and then add other apps like erpnext, etc one by one by adding more folders.
  3. If you have setup virtual environment for bench and frappe, please remember to select the right intrepreter for the dev/debug environment. On Mac, pycharm is picking the actual location of the python symlink in venv and therefore was not able to find other dependencies. You need to go to Add a new intrepreter and then choose virtual environment so that all dependencies are resolved. Search for python intrepreter in pycharm settings and you should get the way. Slighted twisted UX when you need to choose “show all” and then add another one from right panel. Screenshot below.

It is unclear how you have shaped the Project structure on Pycharm. Can you elaborate?
Since the product and framework is installed, the directories and the source code is already there. I wonder how your project looks like

I opened as an existing project. I first opened frappe-bench/apps/Frappe into workspace and then added other apps one by one to the project. The structure looks as follows. All apps are independent projects in the same workspace.
Everytime you add another project, the IDE ask if you want to attach to existing project. I choose to attach.

Separately, I tried opening frappe-bench/apps folder into the workspace but I kept getting error while starting the debugger. May be, I will try again at some later point in time.

Debug configurations:
Script path: /apps/frappe/frappe/utils/bench_helper.py
Script Parameters: frappe serve --port=8000 --noreload --nothreading
Working Dir: /erpnext/frappe-bench/sites
Env Variable: PYTHONUNBUFFERED=1;DEV_SERVER=1

comment this line in procfile: web: bench serve --port 8000

If a different port is required, pass that as the script param: