Error “main. Py: error: the following arguments are required:”
1. Check the error message first
As shown in the figure below,
main.py: error: the following arguments are required: -- task, -- dataset, -- param
generally speaking, the three parameters I set task
, dataset
, param
have problems
find the place where I set the parameters and find that these three parameters have the attribute required=True
parser.add_argument("--task", default='uabsa', type=str, required=True,
help="The name of the task, selected from: [uabsa, aste, tasd, aope]")
parser.add_argument("--dataset", default='rest14', type=str, required=True,
help="The name of the dataset, selected from: [laptop14, rest14, rest15, rest16]")
parser.add_argument("--model_name_or_path", default='t5-base', type=str,
help="Path to pre-trained model or shortcut name")
parser.add_argument("--paradigm", default='annotation', type=str, required=True,
help="The way to construct target sentence, selected from: [annotation, extraction]")
2. Solutions
Method 1:
1.Run–> Edit Configurations
2. main.py (corresponding error report file), fill in the corresponding
-- task "uabsa" -- dataset "rest14" -- param "Annotation"
, here are the error report parameters and the corresponding default valuesfor example, here — the default of task is “uabsa”,
note: it is double quotation marks instead of single quotation marks, and there may be problems with single quotation marks
Click OK after filling in.
Method 2: if method 1 and other methods do not work (simple, but not recommended)
Find the set generation of three variables and delete required=True
in the code.
initially
parser.add_argument("--task", default='uabsa', type=str, required=True,
help="The name of the task, selected from: [uabsa, aste, tasd, aope]")
parser.add_argument("--dataset", default='rest14', type=str, required=True,
help="The name of the dataset, selected from: [laptop14, rest14, rest15, rest16]")
parser.add_argument("--model_name_or_path", default='t5-base', type=str,
help="Path to pre-trained model or shortcut name")
parser.add_argument("--paradigm", default='annotation', type=str, required=True,
help="The way to construct target sentence, selected from: [annotation, extraction]")
After deletion
parser.add_argument("--task", default='uabsa', type=str,
help="The name of the task, selected from: [uabsa, aste, tasd, aope]")
parser.add_argument("--dataset", default='rest14', type=str,
help="The name of the dataset, selected from: [laptop14, rest14, rest15, rest16]")
parser.add_argument("--model_name_or_path", default='t5-base', type=str,
help="Path to pre-trained model or shortcut name")
parser.add_argument("--paradigm", default='annotation', type=str,
help="The way to construct target sentence, selected from: [annotation, extraction]")
Read More:
- [Solved] train.py: error: the following arguments are required: –XXXX
- [Solved] error: the following arguments are required (Default parameters are set)
- To solve the problem that the loss of verification set of resnet50 pre-training model remains unchanged
- RuntimeError: Not implemented on the CPU [How to Solve]
- Python+OpenCV: How to Use Background Subtraction Methods
- [Solved] Pytorch-transformers Error: AttributeError: ‘str‘ object has no attribute ‘shape‘
- [Solved] TypeError: __init__() missing 1 required positional argument: ‘on_delete’
- How to Fix Errors encountered in executing Python scripts with command line parameters
- Python custom convolution kernel weight parameters
- Pytorch Loading model error: RuntimeError: Error(s) in loading state_dict for Model: Missing key(s) in state_dict
- Python: How to Delete Empty Files or Folders in the Directory
- Error:output with shape [1, 224, 224] doesn‘t match the broadcast shape [3, 224, 224]
- Keras import a custom metric model error: unknown metric function: Please ensure this object is passed to`custom_object‘
- Python server run code ModuleNotFoundError Error [How to Solve]
- [Solved] RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the
- [Solved] python Error: GuessedAtParserWarning: No parser was explicitly specified
- Python: Panda scramble data
- [Solved] Mindspot error: Error: runtimeerror:_kernel.cc:88 CheckParam] AddN output shape must be equal to input…
- Pointnet-pytorch Error: importError: No module named ‘pointnet‘
- [Solved] ParserError: NULL byte detected. This byte cannot be processed in Python‘s native csv library