搭建gym環境

qq_27389705發表於2019-03-30

之前已經安裝過Anaconda和Git 所以跳過了教程安裝Anaconda和Git的步驟

照書上折騰了半天,發現官網安裝方法比較簡單,安好了就不刪了重弄了(Gym官網)

首先在CMD下輸入命令

conda create --name gymlab python=3.6

安裝的過程如下

C:\WINDOWS\system32>conda create --name gymlab python=3.6
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\MDD\AppData\Local\Continuum\anaconda3\envs\gymlab

  added / updated specs:
    - python=3.6


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pip-19.0.3                 |           py36_0         1.9 MB
    python-3.6.8               |       h9f7ef89_7        20.3 MB
    setuptools-40.8.0          |           py36_0         664 KB
    sqlite-3.27.2              |       he774522_0         941 KB
    wheel-0.33.1               |           py36_0          57 KB
    ------------------------------------------------------------
                                           Total:        23.8 MB

The following NEW packages will be INSTALLED:

  certifi            pkgs/main/win-64::certifi-2019.3.9-py36_0
  pip                pkgs/main/win-64::pip-19.0.3-py36_0
  python             pkgs/main/win-64::python-3.6.8-h9f7ef89_7
  setuptools         pkgs/main/win-64::setuptools-40.8.0-py36_0
  sqlite             pkgs/main/win-64::sqlite-3.27.2-he774522_0
  vc                 pkgs/main/win-64::vc-14.1-h0510ff6_4
  vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.15.26706-h3a45250_0
  wheel              pkgs/main/win-64::wheel-0.33.1-py36_0
  wincertstore       pkgs/main/win-64::wincertstore-0.2-py36h7fe50ca_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
pip-19.0.3           | 1.9 MB    | ############################################################################ | 100%
python-3.6.8         | 20.3 MB   | ############################################################################ | 100%
wheel-0.33.1         | 57 KB     | ############################################################################ | 100%
setuptools-40.8.0    | 664 KB    | ############################################################################ | 100%
sqlite-3.27.2        | 941 KB    | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > activate gymlab
#
# To deactivate an active environment, use:
# > deactivate
#
# * for power-users using bash, you must source
#

然後在python工作目錄clone gym包

git clone https://github.com/openai/gym.git

過程如下

git clone https://github.com/openai/gym.git
Cloning into 'gym'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 9222 (delta 0), reused 0 (delta 0), pack-reused 9219
Receiving objects: 100% (9222/9222), 3.70 MiB | 213.00 KiB/s, done.
Resolving deltas: 100% (6247/6247), done.

安裝

pip install –e ‘.[all]’

按照教程安裝gym報錯一堆- -,提示使用如下命令

python -m pip install --upgrade pip

emmm,女朋友搶網,不小心升級一半取消了,解除安裝了pip…*(用pip解除安裝了pip,哎)
搜尋教程,重灌一下pip…

python -m pip uninstall pip
easy_install.exe pip

提示無效的命令 -e…頭疼

Invalid requirement: '–e'

emmm,原來是複製pdf書上的命令有問題,看了Git上的說明,應該是

pip install -e .

安裝過程報了2個錯誤

pip install -e .
Obtaining file:///C:/Users/MDD/Documents/VS%20Code/Python/gym
Requirement already satisfied: scipy in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages (from gym==0.12.1) (1.1.0)
Requirement already satisfied: numpy>=1.10.4 in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages (from gym==0.12.1) (1.14.3)
Requirement already satisfied: requests>=2.0 in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages (from gym==0.12.1) (2.18.4)
Requirement already satisfied: six in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages (from gym==0.12.1) (1.11.0)
Requirement already satisfied: pyglet>=1.2.0 in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages\pyglet-1.4.0b1-py3.6.egg (from gym==0.12.1) (1.4.0b1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages (from requests>=2.0->gym==0.12.1) (3.0.4)
Requirement already satisfied: idna<2.7,>=2.5 in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages (from requests>=2.0->gym==0.12.1) (2.6)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages (from requests>=2.0->gym==0.12.1) (1.22)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages (from requests>=2.0->gym==0.12.1) (2019.3.9)
Requirement already satisfied: future in c:\users\mdd\appdata\local\continuum\anaconda3\lib\site-packages\future-0.16.0-py3.6.egg (from pyglet>=1.2.0->gym==0.12.1) (0.16.0)
pommerman 0.2.0 has requirement Flask~=0.12, but you'll have flask 1.0.2 which is incompatible.
pommerman 0.2.0 has requirement pylint~=1.9.2, but you'll have pylint 1.8.4 which is incompatible.
Installing collected packages: gym
  Found existing installation: gym 0.10.5
    Uninstalling gym-0.10.5:
      Successfully uninstalled gym-0.10.5
  Running setup.py develop for gym
Successfully installed gym

pommerman 0.2.0 has requirement Flask~=0.12, but you’ll have flask 1.0.2 which is incompatible.
pommerman 0.2.0 has requirement pylint~=1.9.2, but you’ll have pylint 1.8.4 which is incompatible.
應該是說了2個不相容,pommerman0.2.0這個環境需要的環境,其中flask應該為0.12我的是1.0.2不相容,pylint應該是1.9.2,我的是1.8.4,先跳過把,一會看這兩個包,剩下的應該安裝成功了。