I copied this code from Github, but its not working to me.
Sample Code:
ap = argparse.ArgumentParser()
ap.add_argument("-s", "--source", required=True, help="Path to the source of shapes")
ap.add_argument("-t", "--target", required=True, help="Path to the target image")
args = vars(ap.parse_args())
and this output
usage: detect_leaf.py [-h] -s SOURCE -t TARGET
detect_leaf.py: error: argument -s/--source is required
please help me. thanks
The error message in your question title is pretty obvious.
ap.add_argument("-s", "--source", required=True, help="Path to the source of shapes")
You put required=True
on this parameter. That means it's required. So, if you try to run this script, and don't put a --source
(or -s
) argument on the command line, you will get an error.
If you don't want it to be required, don't put required=True
.
The output you show at the end of the question, on the other hand, cannot possibly come from this code. There is no -src
or -trg
parameter in your argparse
spec. Maybe you're running a completely different program? If so, we can't debug that program by seeing the code to this one.