一、Ubuntu环境下安装步骤
1.安装anaconda
首先下载anaconda,清华镜像:https://repo.continuum.io/archive/
(1)
cd 下载(安装包所在位置)
bash Anaconda3-5.2.0-Linux-x86_64.sh (anaconda的文件名)
(2)设置python的默认版本为新安装的版本
sudo gedit ~/.bsdhrc
添加语句:export PATH=”/home/Hadoop/anaconda3/bin:$PATH”,保存
source ~/.bashrc
或者使用:
echo 'export PATH="/home/user/anaconda3/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
2.安装虚拟环境
(1)创建虚拟环境
conda create --name gymlab python=3.5
(2)激活环境
source activate gymlab
(3)停止使用环境
source deactivate
3.安装gym
(1)安装git
sudo apt install git
失败,试一试:sudo apt-get update
sudo apt-get install git
(2)克隆到git
git clone https://github.com/openai/gym.git
(3)进入gym文件夹
cd gym
(4)完全安装
pip install -e ‘.[all]'(如果出错查看提示命令)
pip install --upgrade setuptools
pip install numpy Matplotlib
pip install opencv-python
(5)配置环境变量
echo 'export PYTHONPATH="home/user/gym:$PATHNONPATH"' >>~/.bashrc
4.安装mujoco-py
cd mujoco-py
cp requirements.txt requirements.dev.txt mujoco_py
cd mujoco_py
pip3 install -r requirements.txt
pip3 install -r requirements.dev.txt
5.安装mujoco
ip3 install -U 'mujoco-py<1.50.2,>=1.50.1'
git clone https://github.com/openai/mujoco-py
cd mujoco-py
pip install -e . --no-cache
6.安装TensorFlow
(1)安装tensorflow
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.1-cp35-cp35m-linux_x86_64.whl
(2)配置环境变量
sudo gedit ~/.bashrc
export PYTHONPATH="/home/user/gym:$PYTHONPATH"
source ~/.bashrc
7.测试(首先激活gymlab)
source activate gymlab
测试代码:
env=gym.make('CartPole-v0')
env.reset()
env.render()