openai / retro

Retro Games in Gym
MIT License
3.35k stars 524 forks source link

AttributeError: 'RetroEnv' object has no attribute 'em' #266

Closed Martyn0324 closed 2 years ago

Martyn0324 commented 2 years ago

Issue summary

I'm trying to test gym-retro to play Street Fighter II Special Champion Edition-Genesis but I keep getting this error:


Traceback (most recent call last):
  File "VIVA.py", line 28, in <module>
    model.learn(total_timesteps=1000000, log_interval=100, reset_num_timesteps=True, callback=checkpoint)
  File "D:\Anaconda\envs\Alive\lib\site-packages\stable_baselines\ppo2\ppo2.py", line 336, in learn
    rollout = self.runner.run(callback)
  File "D:\Anaconda\envs\Alive\lib\site-packages\stable_baselines\common\base_class.py", line 794, in runner
    self._runner = self._make_runner()
  File "D:\Anaconda\envs\Alive\lib\site-packages\stable_baselines\ppo2\ppo2.py", line 101, in _make_runner
    gamma=self.gamma, lam=self.lam)
  File "D:\Anaconda\envs\Alive\lib\site-packages\stable_baselines\ppo2\ppo2.py", line 449, in __init__
    super().__init__(env=env, model=model, n_steps=n_steps)
  File "D:\Anaconda\envs\Alive\lib\site-packages\stable_baselines\common\runners.py", line 31, in __init__
    self.obs[:] = env.reset()
  File "D:\Anaconda\envs\Alive\lib\site-packages\stable_baselines\common\vec_env\dummy_vec_env.py", line 61, in reset
    obs = self.envs[env_idx].reset()
  File "D:\Anaconda\envs\Alive\lib\site-packages\gym\core.py", line 292, in reset
    return self.env.reset(**kwargs)
  File "D:\Python\Projects\wrapper.py", line 202, in reset
    ob = self.env.reset()
  File "D:\Anaconda\envs\Alive\lib\site-packages\gym\core.py", line 278, in reset
    observation = self.env.reset(**kwargs)
  File "D:\Python\Projects\wrapper.py", line 123, in reset
    return self.env.reset(**kwargs)
  File "D:\Anaconda\envs\Alive\lib\site-packages\retro\retro_env.py", line 200, in reset
    self.em.set_state(self.initial_state)
AttributeError: 'RetroEnv' object has no attribute 'em'

I've checked retro_env.py and everything seems ok(I didn't modify it, afterall).

System information

dpcamp commented 2 years ago

My assumption is you got this error from Nicholas Renotte's YT video? I'm not sure what exactly the fix is, but I noticed running the game in a .py script, rather than in a jupyter notebook works for me.

Martyn0324 commented 2 years ago

My assumption is you got this error from Nicholas Renotte's YT video? I'm not sure what exactly the fix is, but I noticed running the game in a .py script, rather than in a jupyter notebook works for me.

No, it was from another class I was watching. Unfortunately, I was already running the code in a .py script. I even tried executing it on Google Collabs, but got the same error.

Syzygianinfern0 commented 2 years ago

Removing env.close() everywhere fixed the error for me.

Martyn0324 commented 2 years ago

Removing env.close() everywhere fixed the error for me.

Hey! Thanks a lot, it worked!