NameError: name 'base' is not defined OpenAI Gym

midawn98 picture midawn98 · Nov 26, 2018 · Viewed 12.7k times · Source

[Note that I am using xvfb-run -s "-screen 0 1400x900x24" jupyter notebook]

I try to run a basic set of commands in OpenAI Gym

import gym
env = gym.make("CartPole-v0")
obs = env.reset()
env.render()

but I get the following error:

...

~/Downloads/yes/lib/python3.7/site-packages/pyglet/gl/__init__.py in <module>()
    225     else:
    226         from .carbon import CarbonConfig as Config
--> 227 del base
    228 
    229 # XXX remove

NameError: name 'base' is not defined

What can I do to fix this?

Answer

Francis QING picture Francis QING · Apr 5, 2019

It's work for me. (And I just met the same problem)

git clone https://github.com/openai/gym.git
cd gym
pip install -e .

You can also have a try,

conda install -c conda-forge pyglet
# pyglet==1.2.4?

Before that, I installed gym with pip, maybe this is the problem.