首页 > 解决方案 > 进程以退出代码 2 结束

问题描述

每当我尝试在 pycharm 中运行对象检测程序时,都会发生以下错误(请参阅跟踪)。你能帮忙弄清楚,如何解决它?

C:\Users\Dell\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 11093 --file C:/Users/Dell/Desktop/image.py
pydev debugger: process 2648 is connecting

Connected to pydev debugger (build 183.5429.31)
usage: image.py [-h] -i IMAGE -p PROTOTXT -m MODEL [-c CONFIDENCE]
image.py: error: the following arguments are required: -i/--image, -p/--prototxt, -m/--model

Process finished with exit code 2

实际上我正在尝试在下一页中运行代码

https://www.pyimagesearch.com/2017/09/11/object-detection-with-deep-learning-and-opencv/ 我的问题是我应该在哪里复制和粘贴......python deep_learning_object_detection.py \ --prototxt MobileNetSSD_deploy.prototxt.txt \ --model MobileNetSSD_deploy.caffemodel --image images/example_01.jpg

标签: python

解决方案


在 PyCharm 的Run菜单中,查找Edit configurations...

每次运行新脚本时,都会为其创建运行配置,您可以在此处在Parameters:框中提供命令行参数。

您可能只想在此处传递参数部分,而不是脚本名称,因此:

\ --prototxt MobileNetSSD_deploy.prototxt.txt \ --model MobileNetSSD_deploy.caffemodel --image images/example_01.jpg

您可能遇到的另一个问题是您的脚本需要在哪个工作目录中运行。您可以从同一个对话框中更改它,位于Working directory:. 您会发现您很少需要更改此对话框中的任何其他字段,尽管我建议在下面给它一个对您来说合理的名称Name:- 默认情况下,它以它正在运行的脚本文件命名。


推荐阅读