Suppose that you are connecting to a server via host machine. This tutorial should be transferable for local debugging.
Suppose that you have conda
installed on server.
- install debugpy using pip
pip install debugpy
- install vscode on host
- install ssh extension and connect to host
- install vscode python extension on server
- create a launch.json, add the following to configurations.
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "127.0.0.1",
"port": 5678
}
}
Suppose that you have a script like this:
#!/bin/bash
python args_test.py \
"This is arg 1" \
"This is arg 2"
- convert the script and use debugpy
#!/bin/bash
python -m debugpy --listen 127.0.0.1:5678 --wait-for-client args_test.py \
"This is arg 1" \
"This is arg 2"
- run the script
bash test.sh
- navigate to the vscode debug panel, select
Python: Attach
and run - test that debugging is working properly