How to debug python code?
-
Hi, we are developing several applications on Onion Omega2. We are porting some of the projects from RPI where we have python apps. On RPI we are using VS Code with Remote SSH extension to write code directly as also debug code through VS Code with Python Debugger extension. When I want to connect from VS Code to Omega2 I get error of unsupported architecture.
Please be so kind and share with me how do you manage coding on Omega2 and if there are any other VS Code extensions with which we could connect directly to Omega2 and also debug python code.
Using print to debug and re-running code is time consuming and unfriendly.
Thanks in advance for answers.
-
@defa85 I don't use VS code but you can debug python code using gdb and you can run a gdb server on Omega2. I mainly develop in C/C++ and debug using gdb remotely.
-
Hi,
I never really found an alternative to just run the code directly on the Omega and use "standard" debugging techniques like "print". We try to work as follows:
- Create a python script which can be mainly tested on the dev machine (PC, Linux, Mac...whatever you are working with)
- Ensure a good logging mechanism in the script in order to be able to write debug infos into log file (always a good thing even once your in production and need to debug a device)
- Once your script is done to 90%, finish debugging on device.
If you find a better solution, I'll be glad to ear from you :-).
Best,