user123
user123

Reputation: 15

Python: No module named 'gym'

I have a really simple error, that plainly says there is no module called 'gym'. Which really sucks, mostly because I've always wanted to use the OpenAI (Gym and Universe) modules. I've run pip install gym and pip install universe without typos in my installation or importing.

Code:

import gym
import universe

env = gym.make('flashgames.CoasterRacer-v0')
obervation_n = env.reset()

while True:
    action_n = [[('KeyEvent', 'ArrowUp', True]) for ob in observation_n]
    observation_n, reward_n, done_n, info = env.step(action_n)
    env.render()

So what's going on, and how can I fix this (I'm using this video)? Thanks.

EDIT: Okay, this is weird. I uninstalled Python, reinstalled it, reinstalled gym and universe, and now it says Universe can't be found. When I install Universe it gives me this error:

Command "python setup.py egg_info" failed with error code 1 in C:\Users\Me\AppData\Local\Temp\pip-install-mdg2jd74\fastzbarlight\

Is this an issue with Universe?

Upvotes: 0

Views: 6826

Answers (1)

AnitaAgrawal
AnitaAgrawal

Reputation: 121

I too was facing the same error. In my case I had created another environment (gym_env) in Anaconda and launched Jupyter Notebook from the gym_env environment. That's why import gym wasn't working, as gym wasn't installed in this environment. When I ran 'pip install gym' from gym_env then it started working.

Upvotes: 1

Related Questions