How to?

python-debug

Jan 23, 2024
softwares-and-toolsvscodedebugpython
1 Minutes
178 Words
This article was last updated on May 27, 2026 and some of the information may no longer be applicable due to the passage of time.

This method is verified!

https://code.visualstudio.com/docs/python/debugging

https://stackoverflow.com/questions/51244223/visual-studio-code-how-debug-python-script-with-arguments

开始

vscode cmd: show run and debug.

click ‘create launch.json’

A file is created.

If you wanna run shell script for python like this:

Terminal window
1
CUDA_VISIBLE_DEVICES=0 python cloth_funnels/run_sim.py \
2
name="demo-single" \
3
load=models/longsleeve_canonicalized_alignment.pth \
4
eval_tasks=assets/tasks/longsleeve-single.hdf5 \
5
eval=True \
6
num_processes=1 \
7
episode_length=10 \
8
wandb=disabled \
9
fold_finish=True \
10
dump_visualizations=True

Add args like, [tested ok]:

1
{
2
// Use IntelliSense to learn about possible attributes.
3
// Hover to view descriptions of existing attributes.
4
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
"version": "0.2.0",
6
"configurations": [
7
{
8
"name": "Python: 当前文件",
9
"type": "python",
10
"request": "launch",
11
"program": "${file}",
12
// "program": "${workspaceFolder}/script/eval_policy.py", // 这样也行
13
"console": "integratedTerminal",
14
"args": ["name=\"demo-single\"",
15
"load=models/longsleeve_canonicalized_alignment.pth",
14 collapsed lines
16
"eval_tasks=assets/tasks/longsleeve-single.hdf5",
17
"eval=True",
18
"num_processes=1",
19
"episode_length=10",
20
"wandb=disabled",
21
"fold_finish=True",
22
"dump_visualizations=True"],
23
"env": {
24
"CUDA_VISIBLE_DEVICES": "0",
25
"HYDRA_FULL_ERROR": "1",
26
},
27
}
28
]
29
}

Switch to the file you want to run (as in launch.json we by default designate “Run current file”, so you have to switch to the exact file to run).

Add a breakpoint,

Click the green delta in “Run python and debug” menu,

Everything is well! And watch params in the menu!

Remote

Using vscode-ssh is also ok to run python debug in remote machine.

Article title:python-debug
Article author:Julyfun
Release time:Jan 23, 2024
Copyright 2026
Sitemap