Debug python files, what method is indicated in Frappe?

Debug python files, what method is indicated in Frappe?

Cheers!

1 Like

easiest way is to use print and keep an eye on your bench console.

1 Like

Thanks, like PHP… :smile:

Hi,

i use the PyCharm IDE. Has an interactive debugger, so i can step to the file. Works grate for me.

How do you do that?

I use PyCharm too, but I don’t know how to start PyCharm Debug in frappe… I use in Django, Flask or Python scripts, but when I try to use in frappe, doesn’t start… :disappointed:

@fuekor Can you share how you setup frappe to boot/init with pycharm debugger.
Or are you using pycharm’s remote debugging?

Hello,

sorry for the late reply. Haven’t seen the message before.
I use the following Debug configuration in Pycharm. It runs on my mac in a fusion ubuntu 12.04 environment:

script: /home/fuekor/frappe-bench/env/bin/frappe
script parameters: site1.local --port=8000 --serve_test
Environment Variables: PYTHONUNBUFFERED=1
python interpreter: /frappe-bench/env
working directory:/home/fuekor/frappe-bench/sites
add content path to python roots: yes
add source roots to python path: yes

that works fine for me. I can start the app through the debug button and debug all python files within PyCharm.

Hope that helped you.
Greets from the Philippines

Ralph

3 Likes

Hello Fuekor,

Thanks your share at first.

I have error “no module for Frappe” befor use PyCharm,
when I set it like you, python interpreter:/home/developer/frappe-bench/env/bin/python
now debug .by file is ok.

But I want to debug each click of a web page.
Do you know I can how to set PyCharm?

It like to follow url video.

“Getting Started with PyCharm 6/8: Debugging” video.
Can see “Running on http://127.0.0.1:5000” in Running window.

Share my configuration:

Environment:
PyCharm5.0 install in my macbook pc,system is OSX EI Capitan,version 10.11.2
Frappe run in Virtual Box,system is Ubuntu 14.10

PyCharm 5.0 Set:

Project Interpreter:
Name:remote-debug
select “Deployment confignration” option
Deployment confignration: project-level server
Deployment Host URL: ssh://root@192.168.31.147:22
Python interpreter path: /home/developer/frappe-bench/env/bin/python
PyCharm helpers path: /root/.pycharm_helps

Tool->Deployment set:

Type:SFTP
SFTP host: 192.168.31.147
Port: 22
Root path: /
User name: root
Auth type: password
Password:*********
Web server root URL: http://192.168.31.147:8000

Mappings:
Local path: /Volumes/erpdev_share/frappe-bench
Deployment path on server ‘project-level server’: /home/developer/frappe-bench
Web path on server ‘project-level server’: /
Project URL: http://192.168.31.147:8000

Excluded Paths: nothing to do it.

Do you know how to debug .py file when click web botton?

Thanks you at first

From Jack.Wang

Try to follow this : https://discuss.frappe.io/t/pycharm-debugging

Did you get this working?

Hi guys, anyone got pycham debugging frappe and custom doctypes. I cannot get it working on custom doctype, I get redis server message error. Appreciate your help. settings
script: /usr/local/bin/bench
script params : start
python: usr/bin/python 2.7
w/dir: usual frappe bench folder

I been having a nightmare getting this to work in Pycharm as well. Have mine running on a remote server and can’t for the life of me get it debugging correctly.

almost giving up on this which is a shame, check this
https://gitter.im/frappe/erpnext?at=57f0dc1a6f39416b1cdffc70
if it can be of any help. I could not get it to work though.