【发布时间】:2019-11-18 15:32:15
【问题描述】:
我正在尝试在无头服务器中运行健身房并在 jupyter 中呈现相同的内容。 Python 2.7 版。
我已经使用xvfb-run -a -s "-screen 0 1400x900x24" jupyter notebook启动了jupyter
下面是我运行的 Jupyte 单元。
import matplotlib.pyplot as plt
import gym
from IPython import display
%matplotlib inline
env = gym.make('CartPole-v0')
env.reset()
plt.imshow(env.render(mode='rgb_array'))
display.display(plt.gcf())
display.clear_output(wait=True)
env.step(env.action_space.sample()) # take a random action
env.close()
但我得到的错误如下:
AttributeError: 'ImageData' object has no attribute 'data'
我在论坛上搜索了很多,但找不到解决方案。在此先感谢您帮助我修复此错误并让我在 jupyter notebook 中渲染健身房。
【问题讨论】:
-
一段时间后,我选择使用 Python 3 并使用下面的链接进行 jupyter 设置。它奏效了。 digitalocean.com/community/tutorials/…
标签: python python-2.7 jupyter-notebook pyglet openai-gym