Windows Python错误:其中一个参数是必需的

Windows Python错误:其中一个参数是必需的,windows,python-2.7,Windows,Python 2.7,我试图从github运行一段代码,该代码使用Python对图像进行分类,但我遇到了一个错误 代码如下: import argparse as ap import cv2 import imutils import numpy as np import os from sklearn.svm import LinearSVC from sklearn.externals import joblib from scipy.cluster.vq import * # Get the path

我试图从github运行一段代码,该代码使用Python对图像进行分类,但我遇到了一个错误

代码如下:

import argparse as ap
import cv2
import imutils 
import numpy as np
import os
from sklearn.svm import LinearSVC
from sklearn.externals import joblib
from scipy.cluster.vq import *



# Get the path of the testing set
parser = ap.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("-t", "--testingSet", help="Path to testing Set")
group.add_argument("-i", "--image", help="Path to image")
parser.add_argument('-v',"--visualize", action='store_true')
args = vars(parser.parse_args())

# Get the path of the testing image(s) and store them in a list
image_paths = []
if args["testingSet"]:
    test_path = args["testingSet"]
    try:
         testing_names = os.listdir(test_path)
    except OSError:
        print "No such directory {}\nCheck if the file exists".format(test_path)
        exit()
for testing_name in testing_names:
        dir = os.path.join(test_path, testing_name)
        class_path = imutils.imlist(dir)
        image_paths+=class_path
    else:
        image_paths = [args["image"]]
这是我收到的错误信息

usage: getClass.py [-h]
               (- C:/Users/Lenovo/Downloads/iris/bag-of-words-master/dataset/test TESTINGSET | - C:/Users/Lenovo/Downloads/iris/bag-of-words-master/dataset/test/test_1.jpg IMAGE)
               [- C:/Users/Lenovo/Downloads/iris/bag-of-words-master/dataset]
getClass.py: error: one of the arguments - C:/Users/Lenovo/Downloads/iris/bag-of-words-master/dataset/test/--testingSet - C:/Users/Lenovo/Downloads/iris/bag-of-words-master/dataset/test/test_1.jpg/--image is required

你能帮我做这个吗?我应该在哪里以及如何写入文件路径

这是您自己的程序发出的错误。消息不是关于文件路径,而是关于参数的数量。这条线

group = parser.add_mutually_exclusive_group(required=True)
表示只允许一个命令行参数-t,-i。但是从错误消息中可以看出,您在命令行上同时提供了-testingSet和-image

因为你只有3个参数,我想知道你是否真的需要参数组

要使命令行正常工作,请删除互斥组并直接将参数添加到解析器中

parser.add_argument("-t", "--testingSet", help="Path to testing Set")
parser.add_argument("-i", "--image", help="Path to image")
parser.add_argument('-v',"--visualize", action='store_true')

你试过的确切命令是什么?