Skip to content
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

[Bug]: Cannot enjoy due to error Cannot convert space of type Discrete(7). Please upgrade your code to gymnasium. #425

Open
notshashwat opened this issue Nov 21, 2023 · 1 comment
Labels
bug Something isn't working custom gym env Issue related to Custom Gym Env

Comments

@notshashwat
Copy link

notshashwat commented Nov 21, 2023

🐛 Bug

I am trying to get the following code to work on kaggle. I have already trained the agent which worked fine but when i run the following :

$ python -m rl_zoo3.enjoy --algo ppo --env MiniGrid-Unlock-v0

I have done the following installations on kaggle:

!git clone --recursive https://github.com/DLR-RM/rl-baselines3-zoo
!pip install -e rl-baselines3-zoo/
!pip install minigrid
!pip install shimmy>=0.2.1
!pip install stable_baselines3

To Reproduce

python -m rl_zoo3.enjoy --algo ppo --env MiniGrid-Unlock-v0

Relevant log output / Error message

/opt/conda/lib/python3.10/site-packages/gym/envs/registration.py:307: DeprecationWarning: The package name gym_minigrid has been deprecated in favor of minigrid. Please uninstall gym_minigrid and install minigrid with `pip install minigrid`. Future releases will be maintained under the new package name minigrid.
  fn()
Loading latest experiment, id=1
Loading rl-trained-agents/ppo/MiniGrid-Unlock-v0_1/MiniGrid-Unlock-v0.zip
/opt/conda/lib/python3.10/site-packages/stable_baselines3/common/vec_env/patch_gym.py:49: UserWarning: You provided an OpenAI Gym environment. We strongly recommend transitioning to Gymnasium environments. Stable-Baselines3 is automatically wrapping your environments in a compatibility layer, which could potentially cause issues.
  warnings.warn(
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/conda/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/kaggle/working/rl-baselines3-zoo/rl_zoo3/enjoy.py", line 276, in <module>
    enjoy()
  File "/kaggle/working/rl-baselines3-zoo/rl_zoo3/enjoy.py", line 156, in enjoy
    env = create_test_env(
  File "/kaggle/working/rl-baselines3-zoo/rl_zoo3/utils.py", line 241, in create_test_env
    env = make_vec_env(
  File "/opt/conda/lib/python3.10/site-packages/stable_baselines3/common/env_util.py", line 125, in make_vec_env
    vec_env = vec_env_cls([make_env(i + start_index) for i in range(n_envs)], **vec_env_kwargs)
  File "/opt/conda/lib/python3.10/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 30, in __init__
    self.envs = [_patch_env(fn()) for fn in env_fns]
  File "/opt/conda/lib/python3.10/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 30, in <listcomp>
    self.envs = [_patch_env(fn()) for fn in env_fns]
  File "/opt/conda/lib/python3.10/site-packages/stable_baselines3/common/vec_env/patch_gym.py", line 58, in _patch_env
    return shimmy.GymV26CompatibilityV0(env=env)
  File "/opt/conda/lib/python3.10/site-packages/shimmy/openai_gym_compatibility.py", line 81, in __init__
    self.action_space = _convert_space(self.gym_env.action_space)
  File "/opt/conda/lib/python3.10/site-packages/shimmy/openai_gym_compatibility.py", line 333, in _convert_space
    raise NotImplementedError(
NotImplementedError: Cannot convert space of type Discrete(7). Please upgrade your code to gymnasium.
@notshashwat notshashwat added the bug Something isn't working label Nov 21, 2023
@araffin
Copy link
Member

araffin commented Nov 21, 2023

Hello,
the error is pretty explicit, you need to upgrade the env code to gymnasium, the RL Zoo doesn't support gym 0.21 since 2.1.0.

EDIT: the error comes from gymnasium, not SB3/RL Zoo

@araffin araffin added the custom gym env Issue related to Custom Gym Env label Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working custom gym env Issue related to Custom Gym Env
Projects
None yet
Development

No branches or pull requests

2 participants