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

Unsupported structured space 'gymnasium.spaces.dict.Dict' #41

Closed
WanqingXia opened this issue Nov 20, 2022 · 5 comments
Closed

Unsupported structured space 'gymnasium.spaces.dict.Dict' #41

WanqingXia opened this issue Nov 20, 2022 · 5 comments
Labels
question Further information is requested

Comments

@WanqingXia
Copy link

I am trying to run your code with stable-baselines3 (code under examples->train_push.py), it seems like stable-baselines does not support the observation space structure defined in gymnasium. How am I suppose to solve this problem?

`
Traceback (most recent call last):
File "/home/wxia612/panda-gym/examples/train_push.py", line 10, in
model = DDPG(policy="MultiInputPolicy", env=env, replay_buffer_class=HerReplayBuffer, verbose=1)
File "/home/wxia612/.local/lib/python3.8/site-packages/stable_baselines3/ddpg/ddpg.py", line 85, in init
super().init(
File "/home/wxia612/.local/lib/python3.8/site-packages/stable_baselines3/td3/td3.py", line 103, in init
super().init(
File "/home/wxia612/.local/lib/python3.8/site-packages/stable_baselines3/common/off_policy_algorithm.py", line 111, in init
super().init(
File "/home/wxia612/.local/lib/python3.8/site-packages/stable_baselines3/common/base_class.py", line 179, in init
env = self._wrap_env(env, self.verbose, monitor_wrapper)
File "/home/wxia612/.local/lib/python3.8/site-packages/stable_baselines3/common/base_class.py", line 228, in _wrap_env
env = DummyVecEnv([lambda: env])
File "/home/wxia612/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 29, in init
self.keys, shapes, dtypes = obs_space_info(obs_space)
File "/home/wxia612/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/util.py", line 67, in obs_space_info
assert not hasattr(obs_space, "spaces"), f"Unsupported structured space '{type(obs_space)}'"
AssertionError: Unsupported structured space '<class 'gymnasium.spaces.dict.Dict'>'

Process finished with exit code 1
`

@WanqingXia WanqingXia added the question Further information is requested label Nov 20, 2022
@qgallouedec
Copy link
Owner

Duplicate #38
Please downgrade to panda-gym==1.1.1

@WanqingXia
Copy link
Author

Hi! thanks for your reply! I just noticed the declaration on top of the code, by following this issue DLR-RM/stable-baselines3#780. I found a way to not downgrade panda-gym and still make the code works.

first install the fix in stable-baselines3: pip install git+https://github.com/carlosluis/stable-baselines3@fix_tests
then add these three lines at the beginning of python code

import sys
import gymnasium
sys.modules["gym"] = gymnasium

@qgallouedec
Copy link
Owner

Great! Thank you for sharing this.

@araffin
Copy link

araffin commented Nov 22, 2022

@qgallouedec I actually found that hack 6 days ago (DLR-RM/stable-baselines3#780 (comment)) and documented it in the PR: DLR-RM/stable-baselines3#780 (comment)

@WanqingXia
Copy link
Author

araffin

I must somehow found your solution and didn't realise that. Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants