Search code examples
pythonvisual-studio-codevscode-debugger

Visual Studio Code Linux python debugger doesn't execute


I'm on a Jetson Nano Linux Ubuntu 18.4, remoting from a windows platform using VS Code to develop python code.

I'm using Visual Studio Code's debugger and expecting the code to stop at several break points. It doesn't. I'm thinking VSC can't find the .py file from the launch.json file? I don't know how to debug launch.json. Any thoughts?

Python code:

#!/usr/bin/python3
import sys
import argparse
print(f'Length : {len(sys.argv)}')
if len(sys.argv) == 2:
    print(f'Argv[1]: {sys.argv[1]}')
if len(sys.argv) == 2:
    name = sys.argv[1]
else:
    name = 'stranger'    
print(f'Hi there, {name}')

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Hello World",
            "type": "python",
            "justMyCode": true,
            "request": "launch",
            "program": "${workspaceFolder}/build/bin/helloWorld.py",
            "args": ["Steven"],
            "console": "integratedTerminal",
            "cwd": "${workspaceFolder}"
        }
    ]
}

The runs without issue from the TERMINAL window: steven@DEVELOPMENT-JETSON:~/Projects/test-python/helloWorld/build/bin$ ./helloWorld.py steven

Length : 2
Argv[1]: steven
Hi there, steven

Attempted 3 Different run attempts in Visual Studio Code:

A. right clicked on helloWorld.py from the Explorer window>> Clicked [Run Python File in Terminal]
   Application runs in TERMINAL window and errors out as expected. 
   Application required an argument e.g $./helloWorld.py Steven. No where to 
   add a parm.
B. clicked Run >> clicked Run without debugging 
   Nothing happens except the debug window flashes on then off.
C. clicked Run >> clicked Start Debugging
   Same result as B

Attached is a image of the Explorer window to show directory locations and break points:

enter image description here


Solution

  • After more research, I found that setting the Interpreter to Python 3.6.9-bit /usr/bin/python3 allowed VSC to enter debug mode. I was using the "Recommended" version. I don't know why VSC required the 3.6.9 version instead of the 3.7.9. I do have the 3.7.9 installed on the jetson.

    enter image description here