使用 PyCharm 终端参数进行调试

Debugging with PyCharm terminal arguments

我使用 PyCharm 有一段时间了,所以我不是专家。

我通常如何 运行 我的程序是这样的终端:

program.py -t input1 -t1 input2

我想知道如何调试它?

对于我写的其他程序,我没有任何参数,所以调试只是设置断点并按下调试。

菜单:Run -> Edit configurations -> "+" (add new config) -> Python.

脚本名称:program.py

如果您需要从已安装的包中调试脚本,例如tox,您也可以指定完整路径。例如: 脚本名称:/home/your_user/.envs/env_name/bin/tox

上方 /home/your_user/.envs/env_name 是包含 tox 包的虚拟环境的路径。

脚本参数:-t input1 -t1 input2

几乎是正确的,但只需要用完整的脚本路径稍作更正。

菜单:Run->Edit configurations->"+" (add new config)->Python.

脚本名称:path + /program.py

脚本参数:-t input1 -t1 input2

只是答案的图像表示

第 1 步:单击 Run 菜单单击 Edit configuration

  1. Select + 在右上角和 select python

  1. 提供nameabsolutepath of the script/ select the script by clicking three dots(green markerscript paramterspython interpreter