首页 > 解决方案 > 从介绍页面运行演示的 OpenAI Gym 错误

问题描述

我安装了 OpenAI Gym 并尝试运行入门手推车演示 ( https://gym.openai.com/docs/ )。(我在 Colab 笔记本中运行。)

import gym
env = gym.make('CartPole-v0')
env.reset()
for _ in range(1000):
    env.render()
    env.step(env.action_space.sample()) # take a random action

这不会学习,但它应该显示推车和杆子。

当我运行它时,我收到一个警告和一个错误。

WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.

错误由 触发env.render()。Traceback 的底部是

Error occured while running `from pyglet.gl import *`
The original exception was:

ImportError: Library "GL" not found.

我已经安装了 pyOpenGL,如下所示。

!pip install PyOpenGL PyOpenGL_accelerate

对于警告和错误,我将不胜感激。我应该安装另一个 GL 库吗?

谢谢。

标签: google-colaboratory

解决方案


Google Colab 在云中运行。它无法将图形显示发送回您的显示器。

您可以尝试使用本地运行时运行它。 https://research.google.com/colaboratory/local-runtimes.html


推荐阅读