Python-健身房。看不到环境
Python-gym. Does not see the environment
请告诉我可能是什么问题?
只有一个环境正确启动。 (手推车)
import gym
env = gym.make('CarRacing-v0')
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample())
AttributeError Traceback (most recent call last) in ()
1 import gym
----> 2 env = gym.make('CarRacing-v0')
3 env.reset()
4 for _ in range(1000):
5 env.render()
C:\Anaconda3\lib\site-packages\gym-0.15.6-py3.6.egg\gym\envs\registration.py
in make(id, **kwargs)
140
141 def make(id, **kwargs):
--> 142 return registry.make(id, **kwargs)
143
144 def spec(id):
C:\Anaconda3\lib\site-packages\gym-0.15.6-py3.6.egg\gym\envs\registration.py
in make(self, path, **kwargs)
85 logger.info('Making new env: %s', path)
86 spec = self.spec(path)
---> 87 env = spec.make(**kwargs)
88 # We used to have people override _reset/_step rather than
89 # reset/step. Set _gym_disable_underscore_compat = True on
C:\Anaconda3\lib\site-packages\gym-0.15.6-py3.6.egg\gym\envs\registration.py
in make(self, kwargs)
56 env = self.entry_point(_kwargs)
57 else:
---> 58 cls = load(self.entry_point)
59 env = cls(**_kwargs)
60
C:\Anaconda3\lib\site-packages\gym-0.15.6-py3.6.egg\gym\envs\registration.py
in load(name)
16 mod_name, attr_name = name.split(":")
17 mod = importlib.import_module(mod_name)
---> 18 fn = getattr(mod, attr_name)
19 return fn
20
AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing'
我用的不是 anaconda,而是 virtualenv。尽管如此,我最初还是犯了同样的错误。 "Classical" 环境似乎在工作,但 Box2D 游戏却没有。我尝试使用 "pip install Box2D" 单独安装 Box2D,但在安装依赖项 "wheel".
时收到缺少 swig.exe 的错误
要解决这个问题,
- 我下载了 swig,然后将 swig.exe 的路径添加到我的 windows 路径中。
- 然后我卸载了gym和Box2D
- 然后我安装了 gym,然后安装了 Box2D "pip install gym[box2d]"
请告诉我可能是什么问题?
只有一个环境正确启动。 (手推车)
import gym
env = gym.make('CarRacing-v0')
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample())
AttributeError Traceback (most recent call last) in () 1 import gym ----> 2 env = gym.make('CarRacing-v0') 3 env.reset() 4 for _ in range(1000): 5 env.render()
C:\Anaconda3\lib\site-packages\gym-0.15.6-py3.6.egg\gym\envs\registration.py in make(id, **kwargs) 140 141 def make(id, **kwargs): --> 142 return registry.make(id, **kwargs) 143 144 def spec(id):
C:\Anaconda3\lib\site-packages\gym-0.15.6-py3.6.egg\gym\envs\registration.py in make(self, path, **kwargs) 85 logger.info('Making new env: %s', path) 86 spec = self.spec(path) ---> 87 env = spec.make(**kwargs) 88 # We used to have people override _reset/_step rather than 89 # reset/step. Set _gym_disable_underscore_compat = True on
C:\Anaconda3\lib\site-packages\gym-0.15.6-py3.6.egg\gym\envs\registration.py in make(self, kwargs) 56 env = self.entry_point(_kwargs) 57 else: ---> 58 cls = load(self.entry_point) 59 env = cls(**_kwargs) 60
C:\Anaconda3\lib\site-packages\gym-0.15.6-py3.6.egg\gym\envs\registration.py in load(name) 16 mod_name, attr_name = name.split(":") 17 mod = importlib.import_module(mod_name) ---> 18 fn = getattr(mod, attr_name) 19 return fn 20
AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing'
我用的不是 anaconda,而是 virtualenv。尽管如此,我最初还是犯了同样的错误。 "Classical" 环境似乎在工作,但 Box2D 游戏却没有。我尝试使用 "pip install Box2D" 单独安装 Box2D,但在安装依赖项 "wheel".
时收到缺少 swig.exe 的错误要解决这个问题,
- 我下载了 swig,然后将 swig.exe 的路径添加到我的 windows 路径中。
- 然后我卸载了gym和Box2D
- 然后我安装了 gym,然后安装了 Box2D "pip install gym[box2d]"