Gym: Failing right at the start

Created on 13 Mar 2018  路  3Comments  路  Source: openai/gym

I installed Anaconda

opened Anaconda terminal and wrote

pip install gym

This seemed successful

I then opened QtConsole in Anaconda and tried to follow the example in the gym documentation.
Below is the full interaction.

Does this mean gym does not work in Anaconda?

(All this was done in Windows 10.)

Jupyter QtConsole 4.3.1
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

import gym

env = gym.make('CartPole-v0')
WARN: gym.spaces.Box autodetected dtype as . Please provide explicit dtype.

env.reset()
Out[3]: array([-0.04383064, -0.00939404, -0.02216988, -0.0390282 ])

for _ in range(1000):
env.render()
env.step(env.action_space.sample())


NotImplementedError Traceback (most recent call last)
in ()
1 for _ in range(1000):
----> 2 env.render()
3 env.step(env.action_space.sample())
4

~\Anaconda3\lib\site-packages\gym\core.py in render(self, mode)
282
283 def render(self, mode='human'):
--> 284 return self.env.render(mode)
285
286 def close(self):

~\Anaconda3\lib\site-packages\gym\envs\classic_control\cartpole.py in render(self, mode)
105 if self.viewer is None:
106 from gym.envs.classic_control import rendering
--> 107 self.viewer = rendering.Viewer(screen_width, screen_height)
108 l,r,t,b = -cartwidth/2, cartwidth/2, cartheight/2, -cartheight/2
109 axleoffset =cartheight/4.0

~\Anaconda3\lib\site-packages\gym\envs\classic_control\rendering.py in __init__(self, width, height, display)
49 self.width = width
50 self.height = height
---> 51 self.window = pyglet.window.Window(width=width, height=height, display=display)
52 self.window.on_close = self.window_closed_by_user
53 self.isopen = True

~\Anaconda3\lib\site-packages\pyglet\window__init__.py in __init__(self, width, height, caption, resizable, style, fullscreen, visible, vsync, display, screen, config, context, mode)
502
503 if not screen:
--> 504 screen = display.get_default_screen()
505
506 if not config:

~\Anaconda3\lib\site-packages\pyglet\canvas\base.py in get_default_screen(self)
71 :rtype: :class:Screen
72 '''
---> 73 return self.get_screens()[0]
74
75 def get_windows(self):

~\Anaconda3\lib\site-packages\pyglet\canvas\base.py in get_screens(self)
63 :rtype: list of :class:Screen
64 '''
---> 65 raise NotImplementedError('abstract')
66
67 def get_default_screen(self):

NotImplementedError: abstract

All 3 comments

I get the same results .
try running the same code with plain python [ not ipython ]
this worked for me.

Are you running on a system that doesn't have a display? It looks like pyglet can't find a screen. If so you can try not doing the render() call, since you won't be able to see the output anyway.

Closing due to lack of activity.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

david8373 picture david8373  路  4Comments

julian-ramos picture julian-ramos  路  4Comments

tornadomeet picture tornadomeet  路  4Comments

reaIws picture reaIws  路  4Comments

pickittwice picture pickittwice  路  4Comments