'installing box2d gym ai
I want to train DQN on CarRacing environmnet but when I want to import it using bellow command there is an error.
env = gym.make('CarRacing-v0').unwrapped
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_4868/4193301300.py in 16 17 ---> 18 env = gym.make('CarRacing-v0').unwrapped 19 20 # set up matplotlib
~\anaconda3\lib\site-packages\gym\envs\registration.py in make(id, **kwargs)
~\anaconda3\lib\site-packages\gym\envs\registration.py in make(self, path, **kwargs) 127 if ":" in path: 128 mod_name, _sep, id = path.partition(":") --> 129 try: 130 importlib.import_module(mod_name) 131 # catch ImportError for python2.7 compatibility
~\anaconda3\lib\site-packages\gym\envs\registration.py in make(self, **kwargs) 87 88 ---> 89 class EnvRegistry(object): 90 """Register an env by ID. IDs remain stable over time and are 91 guaranteed to resolve to the same environment dynamics (or be
~\anaconda3\lib\site-packages\gym\envs\registration.py in load(name) 26 27 Args: ---> 28 id (str): The official environment ID 29 entry_point (Optional[str]): The Python entrypoint of the environment class (e.g. module.name:Class) 30 reward_threshold (Optional[int]): The reward threshold before the task is considered solved
AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing'
also when I run the code :
pip install gym[all]
I get the error :
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_4868/4193301300.py in 16 17 ---> 18 env = gym.make('CarRacing-v0').unwrapped 19 20 # set up matplotlib
~\anaconda3\lib\site-packages\gym\envs\registration.py in make(id, **kwargs)
~\anaconda3\lib\site-packages\gym\envs\registration.py in make(self, path, **kwargs) 127 if ":" in path: 128 mod_name, _sep, id = path.partition(":") --> 129 try: 130 importlib.import_module(mod_name) 131 # catch ImportError for python2.7 compatibility
~\anaconda3\lib\site-packages\gym\envs\registration.py in make(self, **kwargs) 87 88 ---> 89 class EnvRegistry(object): 90 """Register an env by ID. IDs remain stable over time and are 91 guaranteed to resolve to the same environment dynamics (or be
~\anaconda3\lib\site-packages\gym\envs\registration.py in load(name) 26 27 Args: ---> 28 id (str): The official environment ID 29 entry_point (Optional[str]): The Python entrypoint of the environment class (e.g. module.name:Class) 30 reward_threshold (Optional[int]): The reward threshold before the task is considered solved
AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing'
also when I run the code :
Solution 1:[1]
I think you are using windows for using OpenAI gym which is not officially supported.
Gym installation for windows is not stable. Linux and Mac are officially supported. I recommend this video Installing OpenAI Gym (gym[all]) on Linux, Windows and Mac for installing gym in linux.
You can also use wsl2 in windows which I have tried and it does work.
Also, this doc gym 0.7.4 helped me to set up the display in using wsl2(alias linux server according to the docs).
An individual installation like box2d did not work for me. Try to install all as said in the video(takes a lot of space but there is no other option)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Anonymous |