-
Notifications
You must be signed in to change notification settings - Fork 8.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: reset() got an unexpected keyword argument 'seed' #2531
Comments
In pybullet I just hit the same issue. It's likely going to cause most of the third-party envs to fail. |
@RedTachyon would you mind looking into this? |
I'm confused, are you sure it's gym release 0.21? This was released long before any seeding changes made their way into master. |
Ah shit, I managed to replicate it with pybullet, I think I know what's up. Basically wrappers forward the arguments to the inside environment, and while "new style" environments can accept anything in Thanks for the catch, I think I have an idea on how to fix it, which will be possible thanks to the other change to the reset signature. |
The latest commit in #2515 fixes it for me with pybullet, can someone check it with atari? (for some reason a simple install doesn't work when I try to use it, and I never used atari, so probably some of the ROM stuff is lost on me) |
Thank you so much for fixing this issue @RedTachyon! The latest commit in #2515 also fixes the problem for atari. |
Hey, I am still having this issue with the latest gym release import gym
import numpy as np
import pybullet_envs
env = gym.make("HopperBulletEnv-v0")
env.reset()
env = gym.make("HopperBulletEnv-v0")
env = gym.wrappers.ClipAction(env)
env = gym.wrappers.NormalizeObservation(env)
env = gym.wrappers.TransformObservation(env, lambda obs: np.clip(obs, -10, 10))
env = gym.wrappers.NormalizeReward(env)
env = gym.wrappers.TransformReward(env, lambda reward: np.clip(reward, -10, 10))
env.reset() which yields. So looks like without the wrappers the reset was ok, but with the wrappers, the reset was not ok.
|
Looks like this is an issue with Line 77 in bdde1ed
seed during reset
|
Good catch, this will need a patch, should be fairly simple |
Hello! Thanks to everyone for all the work on this repo. (stable-baselines3) karl@omen:~$ python reps/gym/gym/envs/box2d/bipedal_walker.py |
@karlengblom What is your gym version? Do you have a demo code to replicate this? |
The version is 0.23.0. |
@karlengblom Can you please double check that you have a fresh installation of gym? I can't replicate the issue, and it seems pretty impossible in terms of the code. If you were updating gym from an older version, perhaps there are some |
It works on my end.
|
It works. I mixed up the gym version containing the bipedal_walker.py file itself with the gym version imported by it. It was imported from a python env made for SB3, so version 0.19. Thanks for responses, sorry for the inconvenience. |
For me, the solution is to upgrade gym to the newest version |
Hi, stable baseline3 had been working well in my project, but when using gymnasium, I encountered this error. What should I do to fix it? |
@JonaSi754 Could you provide some code to replicate this |
Sure, I use a custom env. Here is the env I create:
And here is the traceback:
|
@JonaSi754 You need to provide the reset function (and step function), also what gym and sb3 do you use? |
@pseudo-rnd-thoughts sry for confusion, but my original code could be a little bit long. I remove some irrelevant functions.
''' |
Oh, I just find the pattern code also meets the same problem, can you check it |
You either need to downgrade sb3 to 1.X or use the Gym compatibility environment (https://gymnasium.farama.org/content/gym_compatibility/#gym-v0-21-environment-compatibility) as your environment is implemented in gym's v0.21 API not v0.26's api |
thank you very much, I have resolved this! |
Hi, I was also having similar issues with gym_super_mario_bros, where I get the following error: I am currently using: I would appreciate any help!
|
Do you mean the latest version of gym or gymnasium. Thanks! 🙏 |
Install gym 0.18.0 ( |
Agree, using gym instead solves the issue. So we have to use the old deprecated library? |
If you want to use another old deprecated library that's been written for the old deprecated library, then there's a chance you'll have to use an old deprecated library, yes |
I have the similar issue. Any help here please. |
The NES-py wrapper reset function doesn't have a seed parameter therefore it fails |
@JonaSi754 Thanks |
@pseudo-rnd-thoughts, I am using Gym 0.26.0 and stable 2.3.2 and still get the same issue. I thought with v26 this issue should not be there right? |
Hi, I am using the follwowing gym (version = 0.21.0 and commit hash with fixed typo (https://stackoverflow.com/questions/76129688/why-is-pip-install-gym-failing-with-python-setup-py-egg-info-did-not-run-succ) fixed is given below) and stable baselines 3 versions -
I am still facing the above error as mentioned in the original issue ... Does anyone know a final fix for this? That is, what are the correct versions of gym and stable baselines 3 to use so that this gets fixed? Any other things to keep in mind while making our env? Thanks! |
Hello I got the same error able to resolve this problem main problem lies with incompatability issue with latest update with gym, stable-baselines3, and nes-py. Issue: The These are the following latest environment:
from nes_py.wrappers import JoypadSpace
from gym_super_mario_bros import make
from gym_super_mario_bros.actions import SIMPLE_MOVEMENT
from gym.wrappers import GrayScaleObservation
from stable_baselines3.common.vec_env import DummyVecEnv
# Create the environment
env = make('SuperMarioBros-v0', apply_api_compatibility=True, render_mode='rgb_array')
env = JoypadSpace(env, SIMPLE_MOVEMENT)
env = GrayScaleObservation(env, keep_dim=True)
# Wrap in DummyVecEnv
env = DummyVecEnv([lambda: env]) # ERROR occurs here
state = env.reset() The above code fails with the following error: SOLUTION:Root Cause To resolve this issue, we override the from nes_py.wrappers import JoypadSpace
from gym_super_mario_bros import make
from gym_super_mario_bros.actions import SIMPLE_MOVEMENT
from gym.wrappers import GrayScaleObservation
from stable_baselines3.common.vec_env import DummyVecEnv # Custom wrapper to handle both `seed` and `options` arguments
class CustomJoypadSpace(JoypadSpace):
def reset(self, seed=None, options=None, **kwargs):
"""
Overrides the `reset()` method to ignore `seed` and `options` arguments.
"""
return super().reset(**kwargs) # Create the environment
env = gym_super_mario_bros.make('SuperMarioBros-v0', apply_api_compatibility=True, render_mode='rgb_array')
# Simplify the controls
env = CustomJoypadSpace(env, SIMPLE_MOVEMENT)
# Using GrayScaleWrapper to pass image in grayscale
env = GrayScaleObservation(env, keep_dim=True)
# Wrap inside the Dummy Environment
env = DummyVecEnv([lambda: env])
# Test the environment
state = env.reset()
state.shape
print(f"State shape: {state.shape}")
The custom wrapper ensures compatibility with Additional SuggestionsTo avoid such compatibility issues in the future:
Versions Tested
|
There is an issue with the seeds after the Seeding update (#2422).
Code for Imitation:
I am using gym: 0.21.0 and ale_py: 0.7.3.
The text was updated successfully, but these errors were encountered: