Python健身房。看不到环境

时间:2020-02-07 11:59:51

标签: python jupyter-notebook openai-gym

请告诉我可能是什么问题?
只有一种环境可以正确启动。 (手推车)

import gym
env = gym.make('CarRacing-v0')
env.reset()
for _ in range(1000):
    env.render()
    env.step(env.action_space.sample())
(p)中的

AttributeError跟踪(最近一次通话最近) 1个进口体育馆 ----> 2个env = gym.make('CarRacing-v0') 3 env.reset() _在范围(1000)中为4: 5 env.render()

C:\ Anaconda3 \ lib \ site-packages \ gym-0.15.6-py3.6.egg \ gym \ envs \ registration.py 在make(id,** kwargs) 140 141 def make(id,** kwargs): -> 142返回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 在make中(自己,路径,**) 85 logger.info('制作新环境:%s',路径) 86 spec = self.spec(路径) ---> 87 env = spec.make(** kwargs) 88#我们曾经让人们覆盖_reset / _step而不是 89#重置/步骤。设置_gym_disable_underscore_compat = True

C:\ Anaconda3 \ lib \ site-packages \ gym-0.15.6-py3.6.egg \ gym \ envs \ registration.py 在(自己,变态) 56 env = self.entry_point( _kwargs) 其他57条: ---> 58 cls =负载(self.entry_point) 59个环境= cls(** _ kwargs) 60

C:\ Anaconda3 \ lib \ site-packages \ gym-0.15.6-py3.6.egg \ gym \ envs \ registration.py 负载(名称) 16 mod_name,attr_name = name.split(“:”) 17 mod = importlib.import_module(mod_name) ---> 18 fn = getattr(mod,attr_name) 19返回fn 20

AttributeError:模块'gym.envs.box2d'没有属性'CarRacing'

1 个答案:

答案 0 :(得分:1)

我不是使用anaconda,而是virtualenv。但是,最初我有同样的错误。看来“经典”环境正在运行,但Box2D游戏却没有。我尝试使用“ pip install Box2D”分别安装Box2D,但在安装依赖项“ wheel”时收到缺少swig.exe的错误。

要解决此问题,

  • 我下载了swig,然后将swig.exe的路径添加到了Windows路径。
  • 然后我卸载了Gym和Box2D。
  • 然后我安装了Gym,然后使用“ pip install gym [box2d]”安装了Box2D

enter image description here