简体   繁体   English

安装 box2d 健身房 AI

[英]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.我想在 CarRacing environmnet 上训练 DQN,但是当我想使用以下命令导入它时出现错误。

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 ~\AppData\Local\Temp/ipykernel_4868/4193301300.py in 16 17 ---> 18 env = gym.make('CarRacing-v0').unwrapped 19 20 # 设置 matplotlib

~\anaconda3\lib\site-packages\gym\envs\registration.py in make(id, **kwargs) ~\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, 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 make(self, **kwargs) 87 88 ---> 89 class EnvRegistry(object): 90 """通过ID注册一个环境。IDs随着时间的推移保持稳定,并且 91 保证解决相同的环境动态(或

~\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 (eg module.name:Class) 30 reward_threshold (Optional[int]): The reward threshold before the task is considered solved ~\anaconda3\lib\site-packages\gym\envs\registration.py in load(name) 26 27 Args: ---> 28 id (str): 官方环境 ID 29 entry_point (Optional[str]): The环境类的Python入口点(例如module.name:Class) 30 reward_threshold (Optional[int]):任务被认为解决之前的奖励阈值

AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing' AttributeError:模块“gym.envs.box2d”没有属性“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 ~\AppData\Local\Temp/ipykernel_4868/4193301300.py in 16 17 ---> 18 env = gym.make('CarRacing-v0').unwrapped 19 20 # 设置 matplotlib

~\anaconda3\lib\site-packages\gym\envs\registration.py in make(id, **kwargs) ~\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, 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 make(self, **kwargs) 87 88 ---> 89 class EnvRegistry(object): 90 """通过ID注册一个环境。IDs随着时间的推移保持稳定,并且 91 保证解决相同的环境动态(或

~\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 (eg module.name:Class) 30 reward_threshold (Optional[int]): The reward threshold before the task is considered solved ~\anaconda3\lib\site-packages\gym\envs\registration.py in load(name) 26 27 Args: ---> 28 id (str): 官方环境 ID 29 entry_point (Optional[str]): The环境类的Python入口点(例如module.name:Class) 30 reward_threshold (Optional[int]):任务被认为解决之前的奖励阈值

AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing' AttributeError:模块“gym.envs.box2d”没有属性“CarRacing”

also when I run the code :当我运行代码时:

I think you are using windows for using OpenAI gym which is not officially supported.我认为您正在使用 Windows 来使用不受官方支持的 OpenAI gym。
Gym installation for windows is not stable. Windows 的健身房安装不稳定。 Linux and Mac are officially supported.官方支持 Linux 和 Mac。 I recommend this video Installing OpenAI Gym (gym[all]) on Linux, Windows and Mac for installing gym in linux.我推荐这个视频在 Linux、Windows 和 Mac 上安装 OpenAI Gym (gym[all])用于在 linux 中安装健身房。
You can also use wsl2 in windows which I have tried and it does work.您也可以在我尝试过的 Windows 中使用 wsl2,它确实有效。

Also, this doc gym 0.7.4 helped me to set up the display in using wsl2(alias linux server according to the docs).此外,这个 doc gym 0.7.4帮助我使用 wsl2(根据文档别名 linux 服务器)设置显示。

An individual installation like box2d did not work for me.像 box2d 这样的个人安装对我不起作用。 Try to install all as said in the video(takes a lot of space but there is no other option)尝试按照视频中的说明安装所有内容(占用大量空间,但没有其他选择)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM