OpenAI Gym - AttributeError: module 'contextlib' has no attribute 'nullcontext'
OpenAI Gym - AttributeError: module 'contextlib' has no attribute 'nullcontext'
我在尝试 运行 来自 docker docker 计算引擎上的 docker 容器的命令时遇到了这个错误。
这是堆栈跟踪:
Traceback (most recent call last):
File "train.py", line 16, in <module>
from stable_baselines.ppo1 import PPO1
File "/home/selfplay/.local/lib/python3.6/site-packages/stable_baselines/__init__.py", line 3, in <module>
from stable_baselines.a2c import A2C
File "/home/selfplay/.local/lib/python3.6/site-packages/stable_baselines/a2c/__init__.py", line 1, in <module>
from stable_baselines.a2c.a2c import A2C
File "/home/selfplay/.local/lib/python3.6/site-packages/stable_baselines/a2c/a2c.py", line 3, in <module>
import gym
File "/home/selfplay/.local/lib/python3.6/site-packages/gym/__init__.py", line 13, in <module>
from gym.envs import make, spec, register
File "/home/selfplay/.local/lib/python3.6/site-packages/gym/envs/__init__.py", line 10, in <module>
_load_env_plugins()
File "/home/selfplay/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 269, in load_env_plugins
context = contextlib.nullcontext()
AttributeError: module 'contextlib' has no attribute 'nullcontext'
这似乎是 python 3.6 和 gym 的问题。将我的容器升级到 python 3.7 解决了这个问题。
降级gym的版本也可以解决这个问题。我在 python 3.6 中也遇到了这个错误。我把gym的版本从0.21.0降级到0.15.7,然后就修复了。
我在尝试 运行 来自 docker docker 计算引擎上的 docker 容器的命令时遇到了这个错误。
这是堆栈跟踪:
Traceback (most recent call last):
File "train.py", line 16, in <module>
from stable_baselines.ppo1 import PPO1
File "/home/selfplay/.local/lib/python3.6/site-packages/stable_baselines/__init__.py", line 3, in <module>
from stable_baselines.a2c import A2C
File "/home/selfplay/.local/lib/python3.6/site-packages/stable_baselines/a2c/__init__.py", line 1, in <module>
from stable_baselines.a2c.a2c import A2C
File "/home/selfplay/.local/lib/python3.6/site-packages/stable_baselines/a2c/a2c.py", line 3, in <module>
import gym
File "/home/selfplay/.local/lib/python3.6/site-packages/gym/__init__.py", line 13, in <module>
from gym.envs import make, spec, register
File "/home/selfplay/.local/lib/python3.6/site-packages/gym/envs/__init__.py", line 10, in <module>
_load_env_plugins()
File "/home/selfplay/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 269, in load_env_plugins
context = contextlib.nullcontext()
AttributeError: module 'contextlib' has no attribute 'nullcontext'
这似乎是 python 3.6 和 gym 的问题。将我的容器升级到 python 3.7 解决了这个问题。
降级gym的版本也可以解决这个问题。我在 python 3.6 中也遇到了这个错误。我把gym的版本从0.21.0降级到0.15.7,然后就修复了。