搬运一下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函数。