Is it possible to remote debug Python apps in Linux?

Hello! I am interested in developing Python apps on the iMX6ULL SoM using remote debug. I’ve seen here that a Torizon extension is available for Visual Studio Code that enables remote debug, but according to this page, Torizon does not officially support the iMX6ULL SoM.

So, is it possible to remote debug Python apps on the iMX6ULL running Linux/Ångström OS? If yes, then how? Otherwise, what recommendation can you give me?

Thank you,
Cristian M.

Greetings @CristianM,

There should be a multitude of ways to remotely debug python. Most modern IDEs that support python should also have support for remote debugging. While yes you are correct that the ULL isn’t supported with Torizon and therefore our VSCode extension, you may still be able to use VSCode. For example here’s a guide that describes how to set up remote debugging in VSCode with the general Python tools provided: Debugging configurations for Python apps in Visual Studio Code

If IDEs aren’t to your liking then there’s also an entire page of python debugging tools here: PythonDebuggingTools - Python Wiki

You can check the list for which tools support remote debugging.

It should be noted we don’t really support 1 “true” way when it comes to debugging/development workflows as this choice usually comes down to customer preference.

Best Regards,
Jeremias

Thank you for your answer. Yes, I am interested in using VSCode. I will try your suggestions after I will receive the SoM and evaluation board and let you know.

You are welcome.

Best regards,
Jaski

Hi. I just received the board, installed embedded Linux BSP 2.8.7, Python 3 and I am trying to remotely develop/debug over SSH. The problem is that immediately as VSCode connects to the board, it tries and fails to install VSCode Server on the board (which is needed for remote development/debugging). This is the output from VSCode:

[18:33:05.975] Log Level: 2
[18:33:05.981] remote-ssh@0.61.0
[18:33:05.981] win32 x64
[18:33:05.983] SSH Resolver called for "ssh-remote+192.168.1.123", attempt 1
[18:33:05.984] "remote.SSH.useLocalServer": false
[18:33:05.985] "remote.SSH.showLoginTerminal": false
[18:33:05.985] "remote.SSH.remotePlatform": {}
[18:33:05.985] "remote.SSH.sshPath": undefined
[18:33:05.986] "remote.SSH.sshConfigurationFile": undefined
[18:33:05.986] "remote.SSH.useFlock": true
[18:33:05.986] "remote.SSH.lockfilesInTmp": false
[18:33:05.986] "remote.SSH.localServerDownload": auto
[18:33:05.987] "remote.SSH.remoteServerListenOnSocket": false
[18:33:05.987] "remote.SSH.showLoginTerminal": false
[18:33:05.987] "remote.SSH.maxReconnectionAttempts": 9007199254740991
[18:33:05.988] SSH Resolver called for host: 192.168.1.123
[18:33:05.999] Setting up SSH remote "192.168.1.123"
[18:33:06.165] Using commit id "91899dcef7b8110878ea59626991a18c8a6a1b3e" and quality "stable" for server
[18:33:06.171] Install and start server if needed
[18:33:08.123] Checking ssh with "ssh -V"
[18:33:08.215] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

[18:33:08.225] Running script with connection command: ssh -T -D 52926 "192.168.1.123" bash
[18:33:08.231] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[18:33:08.671] > 398fd5e52dfa: running
> e]0;C:\WINDOWS\System32\cmd.exea
[18:33:08.672] Got some output, clearing connection timeout
[18:33:08.767] > Acquiring lock on /home/root/.vscode-server/bin/91899dcef7b8110878ea59626991a18c
> 8a6a1b3e/vscode-remote-lock.root.91899dcef7b8110878ea59626991a18c8a6a1b3e       
[18:33:08.801] > Installing to /home/root/.vscode-server/bin/91899dcef7b8110878ea59626991a18c8a6a
> 1b3e...
> main: line 52: 1607617988%N/1000000: division by 0 (error token is "N/1000000") 
[18:33:08.817] > 398fd5e52dfa%%1%%    
> Downloading with wget
[18:33:14.380] > Download complete
[18:33:14.396] > main: line 52: 1607617994%N/1000000: division by 0 (error token is "N/1000000")
> main: line 60: - : syntax error: operand expected (error token is "- ")        
[18:33:14.411] > main: line 52: 1607617994%N/1000000: division by 0 (error token is "N/1000000")
> 398fd5e52dfa%%2%%
> tar --version:
> tar: unrecognized option '--version'
> BusyBox v1.24.1 (2020-06-10 16:36:39 UTC) multi-call binary.
> 
> Usage: tar -[cxtZzJjahmvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]... 
[18:33:18.944] > main: line 52: 1607617998%N/1000000: division by 0 (error token is "N/1000000")
[18:33:18.949] > main: line 60: - : syntax error: operand expected (error token is "- ")
> ERROR: tar exited with non-0 exit code: 0
> Trigger local server download
> 398fd5e52dfa:trigger_server_download
> platform==linux==
> vscodeArch==armhf==
> destFolder==/home/root/.vscode-server/bin/91899dcef7b8110878ea59626991a18c8a6a1b
> 3e==
> 398fd5e52dfa:trigger_server_download_end
[18:33:18.950] Got request to download on client for {"platform":"linux","arch":"armhf","destFolder":"/home/root/.vscode-server/bin/91899dcef7b8110878ea59626991a18c8a6a1b3e"}
[18:33:18.950] Downloading VS Code server locally...
[18:33:18.956] > 
> Waiting for client to transfer server archive...
> Waiting for /home/root/.vscode-server/bin/91899dcef7b8110878ea59626991a18c8a6a1b
> 3e/vscode-scp-done.flag and vscode-server.tar.gz to exist
> 

I searched how to install VSCode manually, but without success. How should I proceed from here? Or is there another way to remotely debug Python apps from VSCode?

Hmm I admit I’m unfamiliar with this process you’re attempting. Though judging by the logs you provided it seems the process is attempting to use tar on the toradex system. Then it seems to error out since perhaps the version of tar running on the system is older and doesn’t support the commands the process is trying to run.

I notice you’re on our BSP 2.8 which is rather old at this point have you attempted this on our BSP 3.0 or 5.0?

Other than that I would suggest researching and attempting other methods as well. I’m sure there’s other methods for remote debugging that are available to VSCode.

Best Regards,
Jeremias

I’ve tried also with BSP 3.0 and 5.0, but it was unsuccessful. Unfortunately, I do not know/did not find other methods for remote debug.