gpt4 book ai didi

python - 获取错误 : module 'gym' has no attribute 'make'

转载 作者:行者123 更新时间:2023-12-03 23:49:37 50 4
gpt4 key购买 nike

我正在尝试运行 OpenAI-gym 官方文档中提供的基本 OpenAI-gym 程序:

import gym
env = gym.make("CartPole-v1")
observation = env.reset()
for _ in range(1000):
env.render()
action = env.action_space.sample() # your agent here (this takes random actions)
observation, reward, done, info = env.step(action)

if done:
observation = env.reset()
env.close()

但是程序输出如下错误:
AttributeError: module 'gym' has no attribute 'make' .

最佳答案

我发现我已经将我的 python 文件命名为gym.py,这是不允许的并且给出了错误。所需要做的就是删除该文件并将其命名为其他名称,例如 gym_test.py然后它运行良好。

关于python - 获取错误 : module 'gym' has no attribute 'make' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59590152/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com