The use of VScode+python+anaconda and debugging with parameters (Ubuntu) [personal notes]

The premise is that anaconda is installed

vscode installation:
Go to the official website https://code.visualstudio.com/Download to download the .deb installation package
Open the terminal under the installation package path and enter:
sudo dpkg -i installation package name.deb
to install

Install the python plug-in:
After installation, click the 4 square icons on the left, search for python and install the python plug-in (be careful to downgrade the version to 2022.8.1, otherwise the debugging will crash)

Selection of conda environment:
Enter Ctrl+shift+p, and a command prompt will appear.
Enter Python on the command line: select interpret
to select the Python interpreter to use

Run: directly click the play button in the upper right corner
Debug (debug with parameters): Click the play button on the left Run and debug
Click the gear to create a launch.json file, click add configuration in the lower right corner of the file, select python to add configuration, and create a
new one under "justMyCode" An args parameter: (note that it is double-)
"args": [
"–gpu=0",
"–nr_types=5",
"–batch_size=64"
]

When defining parameters without - or –, only name, write the parameter directly without writing the parameter name, eg:
parser.add_argument('config', help='test config file path')
parser.add_argument('checkpoint', help='checkpoint file')

Need to bring -c, -m and the like:
the command line is -c xxx.json

With double bars:
parser.add_argument('–eval', help='xxxx')

Example:
"args": [
"–gpu=0", # digital
"–nr_types", "5",
"config/xxx.yaml", # without -, no need to write the parameter name
"-c", "xxx .json",
'–eval', "mIoU"
]

Switch to the file to be debugged, click the play button on the upper left to run and debug at runtime just like adding parameters on the command line

Guess you like

Origin blog.csdn.net/zoey_peak/article/details/127759214