1、安装gym
pip更改国内镜像源
在windows文件管理器中输入%APPDATA%
会定位到目录C:\Users\Administrator\AppData\Roaming\,在该目录下新建pip文件夹,在pip文件夹下新建pip.ini文件
在新建的pip.ini文件中输入以下内容并保存
[global]
timeout = 6000
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
conda更改国内镜像源
Win+R输入cmd打开命令行窗口,执行命令
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
执行命令 conda config --set show_channel_urls yes
此时目录C:\Users<username>目录下会生成配置文件.condarc
修改上述配置文件,删除上述配置文件.condarc中的第三行(即-default),然后保存
执行命令conda info查看配置信息
测试一下,安装requests,执行命令conda install requests
pip安装gym
$ pip install gym
安装gym下atari_py
$ pip install --no-index -f https://github.com/Kojoley/atari-py/releases atari_py
安装gym下box2D_py
先到 http://www.swig.org/download.html 中下载 swigwin-3.0.12
下载完后,解压缩 d:/swigwin-3.0.12,然后打开 系统环境变量设置
打开:“我的电脑->属性->高级->环境变量->系统变量”
把 d:/swigwin-3.0.12 添加到 path 变量中
重启后执行
$ pip install box2d-py
源码安装
Installing OpenAI Gym and OpenAI Universe
$ git clone https://github.com/openai/gym.git
$ cd gym
$ pip install -e '.[all]'
或
安装atari环境
$ pip install -e '.[atari]'
安装棋盘类游戏
$ pip install -e '.[board_game]'
安装Box2d控制类游戏
$ pip install -e '.[box2d]'
安装经典控制类游戏
$ pip install -e '.[classic_control]'
安装MuJoCo控制类游戏
$ pip install -e '.[mujoco]'
OpenAI Universe
$ git clone https://github.com/openai/universe.git
$ cd universe
$ pip install -e .
2、测试
import gym
env = gym.make('CartPole-v0')
env.reset()
env.render()