为什么在python中执行argparse时出现错误

时间:2019-06-29 16:05:11

标签: python

我无法解析python中用于检测OpenCv,python和dlib眨眼的参数。

ap = argparse.ArgumentParser()
ap.add_argument("-p", "--shape-predictor", required=True,
        help="path to facial landmark predictor")
ap.add_argument("-v", "--video", type=str, default="",
    help="path to input video file")
args = vars(ap.parse_args())
ap.add_argument("-p", "--shape-predictor", required=True)

_StoreAction(option_strings=['-p', '--shape-predictor'], 
dest='shape_predictor', nargs=None, const=None, default=None, type=None, 
choices=None, help=None, metavar=None)
ap.add_argument("-v", "--video", type=str, default="")
_StoreAction(option_strings=['-v', '--video'], dest='video', nargs=None, const=None, default='', type=<class 'str'>, choices=None, help=None, 
metavar=None)

args = vars(ap.parse_args())

usage: [-h] -p SHAPE_PREDICTOR [-v VIDEO]
error: the following arguments are required: -p/--shape-predictor

1 个答案:

答案 0 :(得分:0)

usage: [-h] -p SHAPE_PREDICTOR [-v VIDEO]
error: the following arguments are required: -p/--shape-predictor

是命令行的输出吗?

我不确定,但是您可能忘记设置-p SHAPE_PREDICTOR标志,这似乎是一个强制选项。您的argparser返回错误,因为他的参数不正确