リモートワークエンジニアの最新デスク環境を公開中!

作って動かすALife ―実装を通した人工生命モデル理論入門 ① 環境構築

前回記事「作って動かすALife ―実装を通した人工生命モデル理論入門 購入」編の続きとして、環境構築に取り組んでいきます。

目次

必要環境

  • Python 3.6.3
  • NumPy 1.14.5
  • Vispy 0.5.3
  • PyQt 5.10.1
  • Pyglet 1.3.2
  • Pymunk 5.3.2
  • Pillow 5.1.0
  • Keras 2.2.0
  • TensorFlow 1.8.0

筆者の作業環境

VWware Workstation上のUbuntu。Linuxディストリビューション等は以下を参照

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"

構築していく

python 3.6.3

まあまずはPythonから入れていきましょうか。Anacondaの軽量版のMinicondaという物があるらしいので使ってみる。「Miniconda

落として来れたっぽいのでshellを叩いてみるか

$ ls
Miniconda3-latest-Linux-x86_64.sh

$ sh Miniconda3-latest-Linux-x86_64.sh

叩いたらライセンスみたいなのがずらっと出てきて入力待機になった、進めていく

>>> yes

Miniconda3 will now be installed into this location:
/home/XXX/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/XXX/miniconda3] >>> 
PREFIX=/home/XXX/miniconda3
installing: python-3.7.3-h0371630_0 ...
Python 3.7.3
installing: ca-certificates-2019.1.23-0 ...
installing: libgcc-ng-8.2.0-hdf63c60_1 ...
installing: libstdcxx-ng-8.2.0-hdf63c60_1 ...
installing: libffi-3.2.1-hd88cf55_4 ...
installing: ncurses-6.1-he6710b0_1 ...
installing: openssl-1.1.1b-h7b6447c_1 ...
installing: xz-5.2.4-h14c3975_4 ...
installing: yaml-0.1.7-had09818_2 ...
installing: zlib-1.2.11-h7b6447c_3 ...
installing: libedit-3.1.20181209-hc058e9b_0 ...
installing: readline-7.0-h7b6447c_5 ...
installing: tk-8.6.8-hbc83047_0 ...
installing: sqlite-3.27.2-h7b6447c_0 ...
installing: asn1crypto-0.24.0-py37_0 ...
installing: certifi-2019.3.9-py37_0 ...
installing: chardet-3.0.4-py37_1 ...
installing: idna-2.8-py37_0 ...
installing: pycosat-0.6.3-py37h14c3975_0 ...
installing: pycparser-2.19-py37_0 ...
installing: pysocks-1.6.8-py37_0 ...
installing: ruamel_yaml-0.15.46-py37h14c3975_0 ...
installing: six-1.12.0-py37_0 ...
installing: cffi-1.12.2-py37h2e261b9_1 ...
installing: setuptools-41.0.0-py37_0 ...
installing: cryptography-2.6.1-py37h1ba5d50_0 ...
installing: wheel-0.33.1-py37_0 ...
installing: pip-19.0.3-py37_0 ...
installing: pyopenssl-19.0.0-py37_0 ...
installing: urllib3-1.24.1-py37_0 ...
installing: requests-2.21.0-py37_0 ...
installing: conda-4.6.14-py37_0 ...
installation finished.
Do you wish the installer to initialize Miniconda3
by running conda init? [yes|no]
[no] >>> yes
no change     /home/XXX/miniconda3/condabin/conda
no change     /home/XXX/miniconda3/bin/conda
no change     /home/XXX/miniconda3/bin/conda-env
no change     /home/XXX/miniconda3/bin/activate
no change     /home/XXX/miniconda3/bin/deactivate
no change     /home/XXX/miniconda3/etc/profile.d/conda.sh
no change     /home/XXX/miniconda3/etc/fish/conf.d/conda.fish
no change     /home/XXX/miniconda3/shell/condabin/Conda.psm1
no change     /home/XXX/miniconda3/shell/condabin/conda-hook.ps1
no change     /home/XXX/miniconda3/lib/python3.7/site-packages/xonsh/conda.xsh
no change     /home/XXX/miniconda3/etc/profile.d/conda.csh
modified      /home/XXX/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

If you'd prefer that conda's base environment not be activated on startup, 
   set the auto_activate_base parameter to false: 

conda config --set auto_activate_base false

Thank you for installing Miniconda3!

インストール出来たみたい。パスを通すために.zshrcに以下を追記

export PATH=$HOME/miniconda3/bin:$PATH

そして一旦読み込む

$ source .zshrc

したらばcondaコマンドが通る事を確認。やったぜ。

$ conda info

     active environment : None
       user config file : /home/XXX/.condarc
 populated config files : 
          conda version : 4.6.14
    conda-build version : not installed
         python version : 3.7.3.final.0
       base environment : /home/XXX/miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/XXX/miniconda3/pkgs
                          /home/XXX/.conda/pkgs
       envs directories : /home/XXX/miniconda3/envs
                          /home/XXX/.conda/envs
               platform : linux-64
             user-agent : conda/4.6.14 requests/2.21.0 CPython/3.7.3 Linux/4.4.0-145-generic ubuntu/16.04.3 glibc/2.23
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

したらば、今回のalife用に環境を作成する。

$ conda create -n "alife" python=3.6.3                                                                              ✘ 1 
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/XXX/miniconda3/envs/alife

  added / updated specs:
    - python=3.6.3


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2019.5.15  |                0         133 KB
    certifi-2019.3.9           |           py36_0         155 KB
    openssl-1.0.2s             |       h7b6447c_0         3.1 MB
    pip-19.1.1                 |           py36_0         1.9 MB
    python-3.6.3               |       h6c0c0dc_5        29.0 MB
    setuptools-41.0.1          |           py36_0         656 KB
    sqlite-3.28.0              |       h7b6447c_0         1.9 MB
    wheel-0.33.4               |           py36_0          40 KB
    ------------------------------------------------------------
                                           Total:        36.9 MB

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/linux-64::ca-certificates-2019.5.15-0
  certifi            pkgs/main/linux-64::certifi-2019.3.9-py36_0
  libedit            pkgs/main/linux-64::libedit-3.1.20181209-hc058e9b_0
  libffi             pkgs/main/linux-64::libffi-3.2.1-hd88cf55_4
  libgcc-ng          pkgs/main/linux-64::libgcc-ng-8.2.0-hdf63c60_1
  libstdcxx-ng       pkgs/main/linux-64::libstdcxx-ng-8.2.0-hdf63c60_1
  ncurses            pkgs/main/linux-64::ncurses-6.1-he6710b0_1
  openssl            pkgs/main/linux-64::openssl-1.0.2s-h7b6447c_0
  pip                pkgs/main/linux-64::pip-19.1.1-py36_0
  python             pkgs/main/linux-64::python-3.6.3-h6c0c0dc_5
  readline           pkgs/main/linux-64::readline-7.0-h7b6447c_5
  setuptools         pkgs/main/linux-64::setuptools-41.0.1-py36_0
  sqlite             pkgs/main/linux-64::sqlite-3.28.0-h7b6447c_0
  tk                 pkgs/main/linux-64::tk-8.6.8-hbc83047_0
  wheel              pkgs/main/linux-64::wheel-0.33.4-py36_0
  xz                 pkgs/main/linux-64::xz-5.2.4-h14c3975_4
  zlib               pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3


Proceed ([y]/n)? y


Downloading and Extracting Packages
setuptools-41.0.1    | 656 KB    | ################################################################################## | 100% 
openssl-1.0.2s       | 3.1 MB    | ################################################################################## | 100% 
sqlite-3.28.0        | 1.9 MB    | ################################################################################## | 100% 
wheel-0.33.4         | 40 KB     | ################################################################################## | 100% 
certifi-2019.3.9     | 155 KB    | ################################################################################## | 100% 
ca-certificates-2019 | 133 KB    | ################################################################################## | 100% 
pip-19.1.1           | 1.9 MB    | ################################################################################## | 100% 
python-3.6.3         | 29.0 MB   | ################################################################################## | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > conda activate alife
#
# To deactivate an active environment, use:
# > conda deactivate

python 3.6.3として使えている & miniconda配下のpythonを見に行っている事を確認。

ひとまずPythonについてはこれで良さそう。初Miniconda!

$ source activate alife
(alife) ~ ❯❯❯ python --version
Python 3.6.3 :: Anaconda, Inc.
(alife) ~ ❯❯❯ which python
/home/XXX/miniconda3/envs/alife/bin/python

NumPy 1.14.5

$ conda install NumPy==1.14.5
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/XXX/miniconda3/envs/alife

  added / updated specs:
    - numpy==1.14.5


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    blas-1.0                   |              mkl           6 KB
    intel-openmp-2019.4        |              243         876 KB
    libgfortran-ng-7.3.0       |       hdf63c60_0         1.3 MB
    mkl-2018.0.3               |                1       198.7 MB
    mkl_fft-1.0.6              |   py36h7dd41cf_0         150 KB
    mkl_random-1.0.1           |   py36h4414c95_1         373 KB
    numpy-1.14.5               |   py36h1b885b7_4          35 KB
    numpy-base-1.14.5          |   py36hdbf6ddf_4         4.1 MB
    ------------------------------------------------------------
                                           Total:       205.5 MB

Vispy 0.5.3

$ conda install Vispy==0.5.3                                                                                ✘ 1 
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/XXX/miniconda3/envs/alife

  added / updated specs:
    - vispy==0.5.3


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    fontconfig-2.13.0          |       h9420a91_0         291 KB
    freetype-2.9.1             |       h8a8886c_1         822 KB
    icu-58.2                   |       h9c2bf20_1        22.5 MB
    libpng-1.6.37              |       hbc83047_0         364 KB
    libuuid-1.0.3              |       h1bed415_2          16 KB
    libxml2-2.9.9              |       he19cac6_0         2.0 MB
    vispy-0.5.3                |   py36hee6b756_0         1.2 MB
    ------------------------------------------------------------
                                           Total:        27.1 MB

PyQt 5.10.1

$ conda install PyQt==5.10.1                                                                                ✘ 1 
Collecting package metadata: done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - pyqt==5.10.1

おや、PyQt 5.10.1は見つからないようです。仕方ないのでバージョン指定無しで行きましょう

$ conda install PyQt                                                                                        ✘ 1 
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/XXX/miniconda3/envs/alife

  added / updated specs:
    - pyqt


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    dbus-1.13.6                |       h746ee38_0         587 KB
    expat-2.2.6                |       he6710b0_0         187 KB
    glib-2.56.2                |       hd408876_0         5.0 MB
    gst-plugins-base-1.14.0    |       hbbd80ab_1         6.3 MB
    gstreamer-1.14.0           |       hb453b48_1         3.8 MB
    icu-58.2                   |       h9c2bf20_1        22.5 MB
    jpeg-9b                    |       h024ee3a_2         248 KB
    libxcb-1.13                |       h1bed415_1         502 KB
    pcre-8.43                  |       he6710b0_0         260 KB
    pyqt-5.9.2                 |   py36h05f1152_2         5.6 MB
    qt-5.9.6                   |       h8703b6f_2        87.1 MB
    sip-4.19.8                 |   py36hf484d3e_0         290 KB
    ------------------------------------------------------------
                                           Total:       132.3 MB

5.9.2みたいですね (心配)

Pyglet 1.3.2

$ conda install Pyglet==1.3.2                                                                               ✘ 1 
Collecting package metadata: done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - pyglet==1.3.2

こちらもない様子。。。暗雲立ち込める。。。

$ conda install Pyglet                                                                                      ✘ 1 
Collecting package metadata: done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - pyglet
Nix
Nix
バージョン指定なしでも無いだと?
(というかどこを見に行っているんだ感が出てきた)

ちょっとググったら出てきました。

[blogcard url=”https://anaconda.org/conda-forge/pyglet”]

以下コマンドで行けるようです。

$ conda install -c conda-forge pyglet                                                                       ✘ 1 
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/XXX/miniconda3/envs/alife

  added / updated specs:
    - pyglet


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2019.3.9   |       hecc5488_0         146 KB  conda-forge
    certifi-2019.3.9           |           py36_0         149 KB  conda-forge
    openssl-1.0.2r             |       h14c3975_0         3.1 MB  conda-forge
    pyglet-1.3.2               |        py36_1000         2.1 MB  conda-forge
    ------------------------------------------------------------
                                           Total:         5.5 MB

Pymunk 5.3.2

$ conda install Pymunk==5.3.2
Collecting package metadata: done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - pymunk==5.3.2

こちらも無し、仕方ない

$ conda install Pymunk                                                                                      ✘ 1 
Collecting package metadata: done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - pymunk

。。。。以下を使いましょう

[blogcard url=”https://anaconda.org/conda-forge/pymunk”]

conda install -c conda-forge pymunk                                                                       ✘ 1 
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/XXX/miniconda3/envs/alife

  added / updated specs:
    - pymunk


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cffi-1.12.3                |   py36h8022711_0         218 KB  conda-forge
    pycparser-2.19             |           py36_1         173 KB  conda-forge
    pymunk-5.5.0               |   py36h516909a_0         595 KB  conda-forge
    ------------------------------------------------------------
                                           Total:         986 KB

Pillow 5.1.0

conda install Pillow==5.1.0
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/XXX/miniconda3/envs/alife

  added / updated specs:
    - pillow==5.1.0


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2019.3.9           |           py36_0         155 KB
    libtiff-4.0.10             |       h2733197_2         604 KB
    olefile-0.46               |           py36_0          48 KB
    pillow-5.1.0               |   py36heded4f4_0         581 KB
    zstd-1.3.7                 |       h0b5b093_0         887 KB
    ------------------------------------------------------------
                                           Total:         2.2 MB

もはや一発で入ることに感動。

Keras 2.2.0

$ conda install Keras==2.2.0
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/XXX/miniconda3/envs/alife

  added / updated specs:
    - keras==2.2.0


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _tflow_select-2.3.0        |              mkl           2 KB
    absl-py-0.7.1              |           py36_0         157 KB
    astor-0.7.1                |           py36_0          43 KB
    c-ares-1.15.0              |       h7b6447c_1          98 KB
    gast-0.2.2                 |           py36_0         138 KB
    grpcio-1.14.1              |   py36h9ba97e2_0         1.0 MB
    h5py-2.9.0                 |   py36h7918eee_0         1.2 MB
    hdf5-1.10.4                |       hb1b8bf9_0         5.3 MB
    keras-2.2.0                |                0           6 KB
    keras-applications-1.0.2   |           py36_0          47 KB
    keras-base-2.2.0           |           py36_0         450 KB
    keras-preprocessing-1.0.1  |           py36_0          45 KB
    libprotobuf-3.7.1          |       hd408876_0         4.7 MB
    markdown-3.1               |           py36_0         113 KB
    protobuf-3.7.1             |   py36he6710b0_0         656 KB
    pyyaml-5.1                 |   py36h7b6447c_0         188 KB
    scipy-1.1.0                |   py36hd20e5f9_0        18.0 MB
    six-1.12.0                 |           py36_0          22 KB
    tensorboard-1.10.0         |   py36hf484d3e_0         3.3 MB
    tensorflow-1.10.0          |mkl_py36hdb377fd_0           4 KB
    tensorflow-base-1.10.0     |mkl_py36h3c3e929_0        82.0 MB
    termcolor-1.1.0            |           py36_1           7 KB
    werkzeug-0.15.4            |             py_0         262 KB
    ------------------------------------------------------------
                                           Total:       117.5 MB

割と容量でかいな

TensorFlow 1.8.0

$ conda install TensorFlow==1.8.0
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/XXX/miniconda3/envs/alife

  added / updated specs:
    - tensorflow==1.8.0


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _tflow_select-1.2.0        |              mkl           2 KB
    bleach-1.5.0               |           py36_0          22 KB
    html5lib-0.9999999         |           py36_0         176 KB
    tensorboard-1.8.0          |   py36hf484d3e_0         3.1 MB
    tensorflow-1.8.0           |       h01c6a4e_0           3 KB
    tensorflow-base-1.8.0      |   py36hee38f2d_0        71.9 MB
    ------------------------------------------------------------
                                           Total:        75.1 MB

環境構築完了

conda listでインストール済みライブラリを確認。

Vispy 0.5.3君が見当たらないけど、再度インストールしようとしたらInstalledになってる。

conda listで出てこないライブラリもあるんですか?教えて下さい詳しい人。

$ conda list
# packages in environment at /home/XXX/miniconda3/envs/alife:
#
# Name                    Version                   Build  Channel
python                    3.6.3                h6c0c0dc_5  
numpy                     1.14.5           py36h1b885b7_4  
pyqt                      5.9.2            py36h05f1152_2  
pyglet                    1.3.2                 py36_1000    conda-forge
pymunk                    5.5.0            py36h516909a_0    conda-forge
pillow                    5.1.0            py36heded4f4_0  
keras                     2.2.0                         0  
tensorflow                1.8.0                h01c6a4e_0

おめでとうございます。ようやく「作って動かすALife」を楽しむ準備が出来ました。出来たはず。 (チュートリアル)

次回は、早速1章から実践して感想交えて書いていきたいと思います。 疲れた。

役に立ったらシェアをお願いします!
  • URLをコピーしました!
  • URLをコピーしました!

コメント

コメントする

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

目次