Remote Debugging for Python
-
Install Visual Studio Code. + https://code.visualstudio.com/docs/?dv=linux64_deb + sudo apt install ~/Downloads/code_1.45.1-1589445302_amd64.deb + Install βPythonβ extension + Python debugging for VSCode:
pip install ptvsd -
Configure application to debug. Example Frappe: +
cat /home/frappe/frappe-bench/Procfile+#web: bench serve --port 8000β> Uncomment to manually start web server + Edit the main app file with debugging port:/home/frappe/frappe-bench/apps/frappe/frappe/app.pypython import ptvsd # By default, remote debugging starts on port 5678 ptvsd.enable_attach(redirect_output=True) print("Now ready for the IDE to connect to the debugger") ptvsd.wait_for_attach() -
Load the code into Visual Studio Code. + Use Rsync via SSH:
rsync -azP frappe@192.168.121.123:/home/frappe/frappe-bench ./ -
Configure Visual Studio Code to connect to the remote debugger. + Start all services:
bench start+ Start web server + debugging port:../env/bin/python ../apps/frappe/frappe/utils/bench_helper.py frappe serve --port 8000 --noreload --nothreading+ Createlaunch.jsonfrom VSCode- Debugging configuration β> Remote Attach β> IP:5678
- Update
HostandRemote rootvalues to sync
