运行python文件出错AttributeError: module ‘gym‘ has no attribute ‘undo_logger_setup‘

搬运一下github上面的解决方案:

This method was deprecated in 0.9.6 and removed in 0.10.8. Since 0.9.6, the logger should not be modifying the global logging configuration, so you shouldn't need to undo anything.

If you do need to call it for some reason, you can check the following code snippet.

 def undo_logger_setup(): 
     """Undoes the automatic logging setup done by OpenAI Gym. You should call 
     this function if you want to manually configure logging 
     yourself. Typical usage would involve putting something like the 
     following at the top of your script: 
  
     gym.undo_logger_setup() 
     logger = logging.getLogger() 
     logger.addHandler(logging.StreamHandler(sys.stderr)) 
     """ 
     root_logger.removeHandler(handler) 
     for logger in _extra_loggers: 
         logger.setLevel(logging.NOTSET) 

You can also check PR #836 that deprecated this method and PR #1154 that removed this method.

翻译一下就是:

该方法在gym0.9.6中被弃用,在gym0.10.8中被删除。由于gym0.9.6,记录器不应该修改全局日志配置,所以您不需要撤销任何东西。

如果出于某种原因需要调用它,则可以检查以下代码片段。

 def undo_logger_setup(): 
     """Undoes the automatic logging setup done by OpenAI Gym. You should call 
     this function if you want to manually configure logging 
     yourself. Typical usage would involve putting something like the 
     following at the top of your script: 
  
     gym.undo_logger_setup() 
     logger = logging.getLogger() 
     logger.addHandler(logging.StreamHandler(sys.stderr)) 
     """ 
     root_logger.removeHandler(handler) 
     for logger in _extra_loggers: 
         logger.setLevel(logging.NOTSET) 

解决方案:

重新安装早期版本的gym就可以,下载指令:

pip install gym==0.10.7  -i https://pypi.tuna.tsinghua.edu.cn/simple

或者也可以在gym/gym/configuration.py中增加上面的undo_logger_setup函数。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值