SystemExit: 2 , args = parser.parse_args() error
Question:
How can I fix this ?
parser = argparse.ArgumentParser()
parser.add_argument("mode", help="Trains or tests the CNN", nargs="*", choices=["train", "continue", "test", "confusionmatrix", "vote", "slice"])
parser.add_argument("--resume", help="The version to continue training from", required=False, default=False)
parser.add_argument("--epochs", help="The number of epochs to finish training from", type=int, required=False, default=False)
args = parser.parse_args()
print("args", args)
I tried
*args, unknown = parser.parse_known_args()
and it doesnt work
Answers:
You can’t leave argument value blank. If your right value is one of them ["train", "continue", "test", "confusionmatrix", "vote", "slice"] then you have to put like this:
parser.add_argument("--mode", help="Trains or tests the CNN", nargs="*", required=False, default='confusionmatrix')
You can replace ‘confusionmatrix’ with any one of them ["train", "continue", "test", "confusionmatrix", "vote", "slice"]
If you get SystemExit: 2 you can try like this:
parser = argparse.ArgumentParser()
parser.add_argument("--mode", help="Trains or tests the CNN", nargs="*", required=False, default='confusionmatrix')
parser.add_argument("--resume", help="The version to continue training from", required=False, default=False)
parser.add_argument("--epochs", help="The number of epochs to finish training from", type=int, required=False, default=100)
parser.add_argument("-f", required=False)
args = parser.parse_args()
print("args", args)
You need to add in the end of " arg_parse.add_argument " line [ parser.add_argument("-f", required=False) ]
How can I fix this ?
parser = argparse.ArgumentParser()
parser.add_argument("mode", help="Trains or tests the CNN", nargs="*", choices=["train", "continue", "test", "confusionmatrix", "vote", "slice"])
parser.add_argument("--resume", help="The version to continue training from", required=False, default=False)
parser.add_argument("--epochs", help="The number of epochs to finish training from", type=int, required=False, default=False)
args = parser.parse_args()
print("args", args)
I tried
*args, unknown = parser.parse_known_args()
and it doesnt work
You can’t leave argument value blank. If your right value is one of them ["train", "continue", "test", "confusionmatrix", "vote", "slice"] then you have to put like this:
parser.add_argument("--mode", help="Trains or tests the CNN", nargs="*", required=False, default='confusionmatrix')
You can replace ‘confusionmatrix’ with any one of them ["train", "continue", "test", "confusionmatrix", "vote", "slice"]
If you get SystemExit: 2 you can try like this:
parser = argparse.ArgumentParser()
parser.add_argument("--mode", help="Trains or tests the CNN", nargs="*", required=False, default='confusionmatrix')
parser.add_argument("--resume", help="The version to continue training from", required=False, default=False)
parser.add_argument("--epochs", help="The number of epochs to finish training from", type=int, required=False, default=100)
parser.add_argument("-f", required=False)
args = parser.parse_args()
print("args", args)
You need to add in the end of " arg_parse.add_argument " line [ parser.add_argument("-f", required=False) ]