pycharm 调试带参数的命令
在使用pycharm调试的过程中,往往会碰到带参数的python命令;因此,无法直接点击run/debug进行调试。本文以笔者要运行命令为例:
python -m algorithms.mFeature_a2c.a2c.train_a2c --env=doom_selfmaze1_10 --experiment=doom_selfmaze1_10-mf
在终端中输入 python --help ,查看python –m的作用:
run library module as a script (terminates option list) (将库模块作为脚本运行)
pycharm 调试带参数命令的具体步骤如下:
1. 点击run/Edit Configurations, 然后点 + 选择python,我将debug名称设置为mFeature;
因为命令中python –m,因此configuration选择module name。
2. 将python -m命令依次输入:
python -m algorithms.mFeature_a2c.a2c.train_a2c --env=doom_selfmaze1_10 --experiment=doom_selfmaze1_10-mf
Module name输入: algorithms.mFeature_a2c.a2c.train_a2c
Parameters:--env=doom_selfmaze1_10 --experiment=doom_selfmaze1_10-mf
3. Environment variables设置:
Python interpreter 选择conda虚拟环境nav下的python; (我的程序在nav下运行)
Working directory 选择程序的根目录。 (我的主程序train_a2c.py在home/z/curious_a2c _vizdoom/algorithms/mFeature_a2c.a2c下)
4. 点击apply 和 ok后,在程序中添加断点;点击run/debug, 选择mFeature即可调试程序