0


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]")
标签: python

本文转载自: https://blog.csdn.net/qq_45056135/article/details/123991879
版权归原作者 CodeWang_NC 所有, 如有侵权,请联系我们删除。

“main.py: error: the following arguments are required:”的评论:

还没有评论