当前位置: 代码迷 >> 综合 >> OpenAI Gym初体验
  详细解决方案

OpenAI Gym初体验

热度:75   发布时间:2024-01-31 09:42:20.0

STEP 1:

miniconda新环境 python 3.7.7

 

STEP 2:

https://github.com/openai/gym

安装openai gym

pip install gym

报了两个包版本不兼容的error:

ERROR: spyder 4.1.4 requires pyqtwebengine<5.13; python_version >= "3", which is not installed.
ERROR: spyder 4.1.4 has requirement pyqt5<5.13; python_version >= "3", but you'll have pyqt5 5.15.0 which is incompatible.

指定一下版本进行安装:

pip install pyqt5==5.12
pip install pyqtwebengine==5.12

一切就绪。

 

安装其他,可能需要sudo:

apt-get install -y libglu1-mesa-dev libgl1-mesa-dev libosmesa6-dev xvfb ffmpeg curl patchelf libglfw3 libglfw3-dev cmake zlib1g zlib1g-dev swig

 

STEP3:

跑个小demo看看

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()