Pyglet 1.4.x breaks visualization code used in RL chapter
I had to downgrade pyglet to 1.3.2 for it to work.
Interesting, thanks for your feedback @thephet. Could you please give more details on your OS, whether you were using Jupyter or not, and what exception or visualization issue you got? Thanks!
OS is ArchLinux. Python is 3.7. I am using jupyter. The code that crashes is:
img = env.render(mode="rgb_array")
img.shape
The error is:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-9-858f7f1e8578> in <module>
----> 1 img = env.render(mode="rgb_array")
2 img.shape
/usr/lib/python3.8/site-packages/gym/core.py in render(self, mode, **kwargs)
233
234 def render(self, mode='human', **kwargs):
--> 235 return self.env.render(mode, **kwargs)
236
237 def close(self):
/usr/lib/python3.8/site-packages/gym/envs/classic_control/cartpole.py in render(self, mode)
186 self.poletrans.set_rotation(-x[2])
187
--> 188 return self.viewer.render(return_rgb_array = mode=='rgb_array')
189
190 def close(self):
/usr/lib/python3.8/site-packages/gym/envs/classic_control/rendering.py in render(self, return_rgb_array)
103 buffer = pyglet.image.get_buffer_manager().get_color_buffer()
104 image_data = buffer.get_image_data()
--> 105 arr = np.frombuffer(image_data.data, dtype=np.uint8)
106 # In https://github.com/openai/gym-http-api/issues/2, we
107 # discovered that someone using Xmonad on Arch was having
When I downgrade to 1.3.2 it works
You can read more about this here: https://github.com/tensorflow/agents/issues/163
I guess it should use get_data instead to support both 1.3 and 1.4. Pyglet 1.4 are just hiding some attributes. There is a lot of compatibility issues in 1.3.x that is fixed in 1.4.x. 1.4.9 just released today.