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 values
for 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)
- [Solved] supervisor Error: /usr/local/lib/python2.7/dist-packages/pkg_resources/py2_warn.py:22: UserWarning: Setuptools will stop working on Python 2
- Tensor for argument #2 ‘mat1‘ is on CPU, but expected it to be on GPU (while checking arguments for
- [Solved] error: unrecognized arguments: –multiprocessing-fork
- [Solved] TypeError: not all arguments converted during string formatting
- Python TypeError: not all arguments converted during string formatting [Solved]
- [Solved] Error: [email protected]: wrong number of arguments (given 1, expected 0)
- [Solved] Error: unrecognized arguments: — no site packages
- Python ValueError: only 2 non-keyword arguments accepted
- [Solved] Matplotlib ERROR: MatplotlibDeprecationWarning: Adding an axes using the same arguments…
- [Solved] TypeError: __init__() missing 1 required positional argument: ‘on_delete’
- Linux Fatal Python error: Py_Initialize Unable to get the locale encoding
- Python pyqt5 ui Generate .py File Error [How to Solve]
- jpeg4py.JPEG(path).decode() Open Image Error [How to Solve]
- Mxnet Export onnx Symbol and params files provided are invalid
- [Solved] SyntaxError: Generator expression must be parenthesized (widgets.py, line 152)
- Python Fatal error: Py_Initialize: unable to load the file system codec
- [Solved] command “python setup.py egg_info“ failed with error code 1