1. 程式人生 > >Ubuntu16.04LTS下搭建強化學習環境gym

Ubuntu16.04LTS下搭建強化學習環境gym

1.安裝Anaconda

去清華映象下載anaconda3_4.3.0-linux-x86_64.sh,然後在終端中輸入以下命令進行安裝:

cd downloads
bash anaconda3_4.3.0-linux-x86_64.sh

2.建立虛擬環境

//gymlab是自己起的虛擬環境名稱 python=x.y指定python版本
conda create --name gymlab python=3.5

3.安裝gym

先重新開啟一個終端,然後遵循以下步驟:

source activate gymlab
pip install gym[all]

這一步可能會出錯
比如:提醒pip版本低,使用如下命令更新:

python -m pip install --upgrade pip

繼續安裝,不出意外,還會報錯:
Failed building wheel for mujoco-py

這個需要自行安裝一下mujoco,可以參考這個方法:
Mujoco以及mujoco_py的安裝
安裝完成之後,重新執行:

pip install gym[all]

保持網路暢通,等待安裝完成,看到如下資訊,說明安裝完成。

Requirement already satisfied: mujoco-py>=1.50; extra == "all" in /home/xtq/mujoco-py (from gym[all]) (1.50.1.65)
Requirement already satisfied: PyOpenGL; extra == "all" in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from gym[all]) (3.1.0)
Requirement already satisfied: future in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from pyglet>=1.2.0->gym[all]) (0.17.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from requests>=2.0->gym[all]) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from requests>=2.0->gym[all]) (2018.8.24)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from requests>=2.0->gym[all]) (1.24)
Requirement already satisfied: idna<2.8,>=2.5 in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from requests>=2.0->gym[all]) (2.7)
Requirement already satisfied: glfw>=1.4.0 in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from mujoco-py>=1.50; extra == "all"->gym[all]) (1.7.0)
Requirement already satisfied: Cython>=0.27.2 in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from mujoco-py>=1.50; extra == "all"->gym[all]) (0.29)
Requirement already satisfied: cffi>=1.10 in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from mujoco-py>=1.50; extra == "all"->gym[all]) (1.11.5)
Requirement already satisfied: lockfile>=0.12.2 in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from mujoco-py>=1.50; extra == "all"->gym[all]) (0.12.2)
Requirement already satisfied: pycparser in /home/xtq/anaconda3/envs/gymlab/lib/python3.5/site-packages (from cffi>=1.10->mujoco-py>=1.50; extra == "all"->gym[all]) (2.19)
Installing collected packages: atari-py, box2d-py, gym
Successfully installed atari-py-0.1.6 box2d-py-2.3.5 gym-0.10.8