gpt4 book ai didi

python - openAi-gym 名称错误

转载 作者:太空狗 更新时间:2023-10-29 17:51:41 24 4
gpt4 key购买 nike

我正在尝试在 WSL 上使用来自 OpenAI 的著名“健身房”模块,并在 python 3.5.2 上执行代码。
当我尝试运行环境时 as explained here ,使用代码:

import gym
env = gym.make('CartPole-v0')
for i_episode in range(20):
observation = env.reset()
for t in range(100):
env.render()
print(observation)
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
if done:
print("Episode finished after {} timesteps".format(t+1))
break

发生这种情况:

Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/home/DrHofstadter/gym/gym/core.py", line 153, in render
return self._render(mode=mode, close=close)
File "/home/DrHofstadter/gym/gym/core.py", line 285, in _render
return self.env.render(mode, close)
File "/home/DrHofstadter/gym/gym/core.py", line 153, in render
return self._render(mode=mode, close=close)
File "/home/DrHofstadter/gym/gym/envs/classic_control/cartpole.py", line 114, in _render
from gym.envs.classic_control import rendering
File "/home/DrHofstadter/gym/gym/envs/classic_control/rendering.py", line 23, in <module>
from pyglet.gl import *
File "/home/DrHofstadter/.local/lib/python3.5/site-packages/pyglet/gl/__init__.py", line 224, in <module>
del base
NameError: name 'base' is not defined

问题类似于this question什么都没有被渲染。 (有问题的 gitterforum 链接不再有效。)

最佳答案

这可能不是这个问题的完美答案,但这是我解决这个问题的经验。

当我从 spyder 运行我的程序时,我遇到了同样的错误。但是当我从终端执行相同的代码时,它没有抛出任何错误。但要为健身房环境正确配置您的语言环境。

关于python - openAi-gym 名称错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44150310/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com