TypeError: load() missing 1 required positional argument: ‘Loader‘?

问题描述

跑模型使用 yam 包l出现以下错误:

File "D:\document\pycharm_project\faster-rcnn.pytorch\lib\model\utils", line 374, in config.pyyaml_cfg = edict(yaml.load(f))
TypeError: load() missing 1 required positional argument: 'Loader'

出错描述:使用 yaml 包 时候报错 TypeError: load() missing 1 required positional argument: ‘Loader‘?

出错原因:请求API时候缺少参数

问题处理

这样的调用API的问题处理肯定是因为版本问题,导致了一些API被废弃,需要先查看版本,然后再决定,两种方式:

  • 降低指定包的版本,确定指定包版本有相关API即可
  • 修改代码(代码修改之处不多的情况下)

1、查看yaml版本

如果是用的 conda ,直接 conda list 即可,可以看到 yaml 包的版本是 6.0。

Yaml 5.1版本之后就弃用了不安全的load加载方式,需要在load方法中加入指定的加载器,或者使用安全加载api, 通过默认加载器使load函数的安全得到加强。

2、问题处理

直接安装指定版本下的 yaml 包即可

pip install pyyaml==5.1

或者修改代码,以下三条选一即可

yaml.load(file,Loader=yaml.FullLoader)yaml.safe_load(file)yaml.load(file, Loader=yaml.CLoader)

再执行就不会报错了

TypeError: load() missing 1 required positional argument: ‘Loader‘?相关推荐

  1. TypeError: load() missing 1 required positional argument: ‘Loader‘解决方案

      大家好,我是爱编程的喵喵.双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中.从事机器学习以及相关的前后端开发工作.曾在阿里云.科大讯飞.CCF等比赛获得多次Top名次.现 ...

  2. TypeError:load() missing 1 required positional argument:‘Loader‘

    参考文章 出现问题 解决问题 原因说明 YAML 5.1版本后弃用了yaml.load(file)这个用法,因为觉得很不安全,5.1版本之后就修改了需要指定Loader,通过默认加载​​器(FullL ...

  3. yaml报错TypeError: load() missing 1 required positional argument: ‘Loader‘

    添加一下命令即可: 我的操作: return yaml.load(config) 改为 return yaml.full_load(config) 问题完美解决

  4. 成功解决TypeError: drop() missing 1 required positional argument: 'labels'

    成功解决TypeError: drop() missing 1 required positional argument: 'labels' 目录 解决问题 解决思路 解决方法 解决问题 TypeEr ...

  5. Django关联数据库时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'...

    sgrade = models.ForeignKey("Grades",) 执行python manage.py makemigrations后出现 TypeError: __in ...

  6. 【bug解决】TypeError: forward() missing 1 required positional argument: ‘x‘

    项目场景: 进行ReLU类的实例运算时,出现了问题 问题描述 import numpy as npclass ReLU():def __init__(self):self.mask = Nonedef ...

  7. TypeError: __new__() missing 1 required positional argument: ‘exemplar‘

    ** TypeError: new() missing 1 required positional argument: 'exemplar' ** 打开jupyter lab报错: TypeError ...

  8. TypeError: __init__() missing 1 required positional argument: 'on_delete' 解决办法

    Django 中创建Model时报以下错误: TypeError: init() missing 1 required positional argument: 'on_delete' 代码如下: f ...

  9. TypeError: fit() missing 1 required positional argument: 'y'

    在我们调用sklearn中的算法时,如果不小心就会遇到下面这样的问题: TypeError: fit() missing 1 required positional argument: 'y' 在fi ...

最新文章

  1. MySQL批量导入数据
  2. ‘fopen‘: this function or variable may be unsafe.
  3. python3 subprocess.Popen 报错 No such file or directory
  4. Hadoop Shell命令
  5. [译]WPF 应用程序和MVVM设计模式 ——Josh Smith
  6. NLP中各框架对变长序列的处理全解
  7. CRM One Order 事件处理元数据初始化的准确位置
  8. python学习过程中随手写的测试脚本-testloop.py
  9. Unity大密度建筑场景加载解决方案
  10. 编程的本质--深入理解类型系统/泛型/函数式编程/面向对象编程
  11. git tag 的基本用法
  12. 2004级C++试题及答案
  13. linux下mysql,linux下mysql的装配
  14. 2023南昌大学计算机考研信息汇总
  15. arm9开发板学习笔记之程序烧录
  16. EV 鼠标被消费者誉为世界“第八大奇迹”内幕
  17. JSR303校验的简单使用以及自定义校验规则的代码编写
  18. logit方程怎么写_家长也能看懂的“一元一次方程解法”,请大家收藏给孩子看!...
  19. lessons learned from the Qlikview loads the data from DB into qvd files
  20. 豆瓣再美好,也只是生活中的一瓣

热门文章

  1. GrayScale灰度切量系统 【AB测试】
  2. 滴滴(夜莺)Nightingale监控部署
  3. .NET通过PowerShell操作ExChange为用户开通邮箱教程
  4. BUUCTF Misc wp大合集(3)
  5. mysql数据库管理工具(navicat for mysql) 10.1.7 绿色中文版
  6. 微软学生开发者峰会收获分享
  7. otb100matlab,OTB(visual tracker benchmark) 的基础环境配置
  8. [Android] 能用的QQ轻聊版,3.7.1 安装后占用 36M 界面简洁,启动速度快
  9. 钢筋连接套筒A做拉伸试验时,钢筋连接套筒被拉断就一定不合格吗?
  10. 机器学习的手势识别应用