简体   繁体   English

使用PyCharm终端参数进行调试

[英]Debugging with PyCharm terminal arguments

I have been using PyCharm for a bit so I am not an expert. 我已经使用PyCharm了一段时间,所以我不是专家。

How I normally ran my programs was with the terminal like so: 我通常如何在终端上运行程序,如下所示:

program.py -t input1 -t1 input2

I was wondering how can I debug this? 我想知道如何调试它?

For other programs I wrote, I did not have any arguments so debugging was simply setting break points and pressing debug. 对于我编写的其他程序,我没有任何参数,因此调试只是设置断点并按debug。

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

Script name: program.py 脚本名称: program.py

If you need to debug a script from installed packages, such as tox , you can specify the full path too. 如果您需要从已安装的软件包(例如tox调试脚本,则也可以指定完整路径。 For example: Script name: /home/your_user/.envs/env_name/bin/tox 例如:脚本名称: /home/your_user/.envs/env_name/bin/tox

Above /home/your_user/.envs/env_name is a path to virtual environment containing tox package. /home/your_user/.envs/env_name上方是包含tox软件包的虚拟环境的路径。

Script params: -t input1 -t1 input2 脚本参数: -t input1 -t1 input2

Just the image wise representation of answer 只是答案的图像化表示

step 1: Click on the Run menu click Edit configuration 步骤1:单击Run菜单上单击Edit configuration

在此处输入图片说明

  1. Select + in top right corner and select python 选择右上角的+ ,然后选择python

在此处输入图片说明

  1. Provide the name , absolutepath of the script/ select the script by clicking three dots(green marker , script paramters and python interpreter 提供absolutepath of the script/ select the script by clicking three dots(green markernameabsolutepath of the script/ select the script by clicking three dots(green markerscript paramterspython interpreter absolutepath of the script/ select the script by clicking three dots(green marker

在此处输入图片说明

It was almost correct but just needed little correction with full script path. 这几乎是正确的,但只需要很少的完整脚本路径校正即可。

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

Script name: path + /program.py 脚本名称: path + /program.py

Script params: -t input1 -t1 input2 脚本参数: -t input1 -t1 input2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM