我会因env渲染而遇到错误-Env.Render()
我试图在渲染时实现Atari游戏,如下所示:
line 283, in render
raise error.Error(
gym.error.Error: render(mode='human') is deprecated. Please supply `render_mode` when constructing your environment, e.g., gym.make(ID, render_mode='human'). The new `render_mode` keyword argument supports DPI scaling, audio, and native framerates.
我获得的完整错误的屏幕截图在这里。
我的代码如下:
episodes = 5
for episode in range(1, episodes+1):
state = env.reset()
done = False
score = 0
while not done:
env.render()
action = random.choice([0,1,2,3,4,5])
n_state, reward, done, info = env.step(action)
score+=reward
print('Episode:{} Score:{}'.format(episode, score))
env.close()
在堆栈溢出中有类似的帖子,在给出的解决方案中:
pip install pyglet==1.2.4
不幸的是,这也对我不起作用。
I was trying to implement Atari Games while rendering I get an error as given below:
line 283, in render
raise error.Error(
gym.error.Error: render(mode='human') is deprecated. Please supply `render_mode` when constructing your environment, e.g., gym.make(ID, render_mode='human'). The new `render_mode` keyword argument supports DPI scaling, audio, and native framerates.
Screenshot of the complete error I get is attached here.
My code is given below:
episodes = 5
for episode in range(1, episodes+1):
state = env.reset()
done = False
score = 0
while not done:
env.render()
action = random.choice([0,1,2,3,4,5])
n_state, reward, done, info = env.step(action)
score+=reward
print('Episode:{} Score:{}'.format(episode, score))
env.close()
There is a similar post in stack overflow where in the solution given was:
pip install pyglet==1.2.4
Unfortunately this didn't work for me either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我一个人弄清楚了。
解决方案是只通过更新
render_mode ='human'
inenv> env> env> env
:完整代码:
I have figured it out by myself.
The solution was to just change the environment that we are working by updating
render_mode='human'
inenv
:Full code:
升级
Gym
为我工作:PIP安装 - 升级健身房
Upgrading
gym
worked for me:pip install --upgrade gym