我正在尝试在WSL上使用Python 3.5.2执行代码,使用OpenAI的著名“Gym”模块。
当我尝试运行一个环境如此处所述时,使用以下代码:
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
这个问题类似于这个问题,没有任何内容被渲染出来。(问题中提供的gitterforum链接已经失效。)