0

I am new with python and here I am practicing to understand the code by debugging.

python: add_argument for read data set but unable to read data folder.

Please check the attachment and below code.

ap = argparse.ArgumentParser()
## This is a useful line because it adds an option that we are interested in. The input file
ap.add_argument("-d", "--dataset", required=True,
    help="path to input dataset")
## The plot
ap.add_argument("-p", "--plot", type=str, default="plot.png",
    help="path to output loss/accuracy plot")
## The model
ap.add_argument("-m", "--model", type=str,
    default="mask_detector.model",
    help="path to output kite detector model")
## Parse the command line argument
args = vars(ap.parse_args())

Getting the error:

kite_detector.py: error: the following arguments are required: -d/--dataset

but the data with folder name dataset already exists in the project folder in which multiple classification folders.

please provide the link to understand and reason for the getting issue. thanks in advance.enter image description here

[![enter image description here][2]][2]

Nirav Prajapati
  • 265
  • 2
  • 15
  • 1
    You should read about `argparse` and how to work with command line arguments in general. You are defining an `ArgumentParser` and by doing `parse_args` you are trying to read the command line arguments. The script can't *guess* that you want to use that folder – Tomerikoo May 10 '20 at 17:14
  • 1
    Does this answer your question? [Pycharm and sys.argv arguments](https://stackoverflow.com/questions/33102272/pycharm-and-sys-argv-arguments) or https://stackoverflow.com/questions/27952331/debugging-with-pycharm-terminal-arguments – Tomerikoo May 10 '20 at 17:15
  • @Tomerikoo It looks like issues in configuration and setup. I check with [link](https://stackoverflow.com/questions/27952331/debugging-with-pycharm-terminal-arguments) but not getting the result or say not understand that solution, try that edit configuration but still facing the same issue. – Nirav Prajapati May 10 '20 at 17:47
  • Add a screenshot of your Run configurations please – Tomerikoo May 10 '20 at 17:54
  • @Tomerikoo please check ss attached in question. – Nirav Prajapati May 10 '20 at 18:07
  • what is that value? It makse no sense... Just put in the `Parameters` field something like `-d dataset` – Tomerikoo May 10 '20 at 18:09
  • @Tomerikoo yes, sorry i forgot to set the path of -d path of the dataset in the argument, and now its solved the error. thanks – Nirav Prajapati May 11 '20 at 11:19
  • Happy to hear :) Good luck! – Tomerikoo May 11 '20 at 11:20

0 Answers0