openai / gym

A toolkit for developing and comparing reinforcement learning algorithms.
https://www.gymlibrary.dev
Other
34.82k stars 8.61k forks source link

[Bug Report] Atari envs rendering doesn't work #2656

Closed ozzafar closed 2 years ago

ozzafar commented 2 years ago

Hey,

I'm able to render Box2d envs, but when I tried some Atari games I encountered consistantly the following error: ImportError: cannot import name 'rendering' from 'gym.envs.classic_control'.

I'm using python 3.7.6, tried both in mac terminal and in Jupiter notebook. dummy code snippet:

import gym
env = gym.make("ALE/MsPacman-v5")
for i_episode in range(100):
    observation = env.reset()
    for t in range(100):
        env.render()
        print(observation)
        action = env.action_space.sample()
        observation, reward, done, info = env.step(action)
        if done:
            print("Episode finished after {} timesteps".format(t+1))
            break
env.close()

Would be glad for help urgently please! Thanks

luorq3 commented 2 years ago

I am encounting this problem too🥲

luorq3 commented 2 years ago

@ozzafar I already solved this question.

Stop using env.reder() function, just passing a render_mode when initialize your env.

like: env.make('Breakout-v4', render_mode='human')

See: https://github.com/mgbellemare/Arcade-Learning-Environment/blob/master/docs/gym-interface.md

ozzafar commented 2 years ago

indeed solved it, thanks !!!!

likemango commented 2 years ago

thanks!problems solved!

zimonitrome commented 2 years ago

Downgrading to version 0.21.0 also worked