如何修复ipykernel_launcher.py:错误:Jupyter Notebook中无法识别的参数?

时间:2019-08-16 13:41:43

标签: python python-3.x python-3.7

我正在运行这段代码,但出现错误:

usage: ipykernel_launcher.py [-h] [-v VIDEO] [-a MIN_AREA]
ipykernel_launcher.py: error: unrecognized arguments: -f C:\Users\vivek\AppData\Roaming\jupyter\runtime\kernel-727a64d4-d054-4022-a74a-1046dfef03a6.json
An exception has occurred, use %tb to see the full traceback.

SystemExit: 2

我尝试研究argparse,但无法在代码中正确实现它。

我相信整个脚本中的这段代码都会引起问题(尤其是第一部分)。

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-v", "--video", help="path to the video file")
ap.add_argument("-a", "--min-area", type=int, default=50, help="minimum 
area size")
#default 50
args = vars(ap.parse_args())
HD = 768 , 576

#if the video argument is None, then we are reading from webcam
if args.get("video", None) is None:
    camera = cv2.VideoCapture(0)
    time.sleep(0.25)

# otherwise, we are reading from a video file
else:
    camera = cv2.VideoCapture(args["video"])
    tot_f_num = int(camera.get(cv2.CAP_PROP_FRAME_COUNT))
    frame_rate_vid = int(camera.get(cv2.CAP_PROP_FPS))

0 个答案:

没有答案