LucasAlegre / sumo-rl

Reinforcement Learning environments for Traffic Signal Control with SUMO. Compatible with Gymnasium, PettingZoo, and popular RL libraries.
https://lucasalegre.github.io/sumo-rl
MIT License
746 stars 201 forks source link

The algorithm only supports (<class 'gym.spaces.discrete.Discrete'>,) as action spaces but Discrete(4) was provided #122

Closed jhih-ching-yeh closed 2 years ago

jhih-ching-yeh commented 2 years ago

When I executed dqn example, I ran into this problem. AssertionError: The algorithm only supports (<class 'gym.spaces.discrete.Discrete'>,) as action spaces but Discrete(4) was provided Is this the same problem as you mentioned about the gym version? Or is it caused by other reasons?

I hope you can mention the solution. Thanks a lot!

截圖 2022-11-20 上午12 32 22
KevinJeon commented 2 years ago

I had the same error with my custom Pettingzoo env. Try sys.modules["gym"] = gymnasium! in my case, it is solved!

LucasAlegre commented 2 years ago

Thank you @KevinJeon for providing a solution! I'm sorry for the state of the dependencies now, but many changes have been happening in gym (now gymnasium) and PettingZoo and libraries such as stable-baselines and rllib have not been updated yet. Hence, the examples in sumo-rl are currently not working properly, but should be updated as soon as the libraries are updated to the newer versions of gymnasium and PettingZoo.

stephenlp commented 1 year ago

@KevinJeon Hi Kevin, could you tell me where should I put this sys.modules["gym"] = gymnasium ? I have the latest files from the repo (per today, 04.05.2023) I'm still new in the field and facing the same issue. Thanks!

KevinJeon commented 1 year ago

in my case, I just that code in my custom main.py file!