取得" AttributeError:"ImageData"对象没有属性"data"在无头健身房jupyter Python 2.7中 [英] Getting " AttributeError: 'ImageData' object has no attribute 'data' " in headless gym jupyter Python 2.7
问题描述
我正在尝试在无头服务器中运行Gym,并在jupyter中进行渲染. Python版本2.7.
I am trying to run gym in headless server and render the same in jupyter. Python version 2.7.
我已经使用xvfb-run -a -s "-screen 0 1400x900x24" jupyter notebook
下面是我运行的Jupyte单元格.
Below is the Jupyte cell that I run.
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()
但是我得到的错误如下:
But the error I get is as below :
AttributeError: 'ImageData' object has no attribute 'data'
我在论坛上进行了很多搜索,但找不到解决方案.在此先感谢您帮助我解决此错误,并让我在jupyter笔记本中渲染健身.
I have searched a lot in forums but could not find a solution. Thanks in advance to help me fix this error and make me to render gym in jupyter notebook.
推荐答案
我遇到了相同的问题.安装pyglet-v1.3.2
而不是v1.4.1
为我解决了这个问题.
I encountered the same issue. Installing pyglet-v1.3.2
instead of v1.4.1
solved the issue for me.
这篇关于取得" AttributeError:"ImageData"对象没有属性"data"在无头健身房jupyter Python 2.7中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!