main.py: error: the following arguments are required:

Posted GD_Wang1206

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了main.py: error: the following arguments are required:相关的知识,希望对你有一定的参考价值。

报错 “main.py: error: the following arguments are required:”

1.首先查看报错信息

如图下图所示
main.py: error: the following arguments are required: --task, --dataset, --paradigm
大致是说我设置的三个参数task, dataset, paradigm有问题
找到设置参数的地方, 发现这三个参数都有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.解决方法

方法1:

1.Run–>Edit Configurations

2.main.py(相应的报错文件), Parameters 填入 对应的--task "uabsa" --dataset "rest14" --paradigm "annotation",这里是报错的参数和相应的默认值
例如我这里 --task 的 default为 “uabsa”, 注: 是双引号而不是单引号, 单引号可能会出现问题 填入之后点击ok 就没有问题了

方法2: 如是使用方法一和其他方法不管用(简单粗暴,但是不建议)

找到设置的代三个变量代码中 将 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]")

删除之后

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]")

以上是关于main.py: error: the following arguments are required:的主要内容,如果未能解决你的问题,请参考以下文章

main.py:错误:需要以下参数:-i/--image

关于fastapi开启多个服务实例时遇到WARNING: You must pass the application as an import string to enable 'reloa

Kafka查看偏移量报错:WARN WARNING: ConsumerOffsetChecker is deprecated and will be dropped in releases follo

The incident LOST_EVENTS occured on the master. Message: error writing to the binary log, Error_code

Errors occurred during the build. Errors occurred during the build. Errors running builder 'Java

### The error may involve defaultParameterMap ### The error occurred while setting parameters