Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unrecognized arguments: True

Code:

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Build dataset')
    parser.add_argument('--do_plot', action="store_true",
                        help='Plot the images')
    args = parser.parse_args()

Error:

$ python make_dataset.py --do_plot True
usage: make_dataset.py [-h] [--do_plot]           
make_dataset.py: error: unrecognized arguments: True
like image 464
Abhishek Bhatia Avatar asked Oct 26 '25 16:10

Abhishek Bhatia


2 Answers

As you've configured it, the --do_plot option does not take any arguments. A store_true argument in argparse indicates that the very presence of the option will automatically store True in the corresponding variable.

So, to prevent your problem, just stop passing True to --do_plot.

like image 161
Jordan Lewis Avatar answered Oct 29 '25 06:10

Jordan Lewis


You do not need to indicate True as far as I can tell, by just including --do_plot, it is telling it that you wanted to do plot. And plus, you did not configure it to take any arguments.

In the following line of the source code:

if args.do_plot:

If you actually included --do_plot in the command lines, it will be evaluated as True, if not, it will be evaluated as False.

like image 42
Taku Avatar answered Oct 29 '25 05:10

Taku



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!