1 gym安裝
git clone https://github.com/openai/gym.git
cd ~/gym
pip install -e '.[all]'
MuJoCo需要註冊,會出錯,所以先不安裝。
註釋掉 setup.py 文件中和 MuJoCo 有關的安裝選項
vim ~/gym/setup.py
註釋掉下面兩句話
#'mujoco': ['mujoco_py>=1.50', 'imageio'],
#'robotics': ['mujoco_py>=1.50', 'imageio'],
pip install -e '.[all]'
2 universe安裝
cd ~
git clone https://github.com/openai/universe.git
cd ~/universe
pip install -e .
3 測試
測試代碼
import gym
import universe # register the universe environments
from universe import wrappers
env = gym.make('gym-core.PongDeterministic-v0')
env = wrappers.experimental.SafeActionSpace(env)
env.configure(remotes=1)
observation_n = env.reset()
while True:
action_n = [env.action_space.sample() for ob in observation_n]
observation_n, reward_n, done_n, info = env.step(action_n)
env.render()
如果出錯,可能因爲發現是 Gym 的 0.9.6 版本里把 benchmarks 這個包給去了:universe github Issue
所以我們可以卸載 Gym,重新安裝,但是是指定安裝 0.9.5 版本。
cd ~/gym
pip uninstall gym
pip install gym==0.9.5