どこかに向かうらしい話

迷走エンジニアの放浪記

Python3 de 統計解析 on CentOS7

python3.xのインストール

前の記事のCentOS7バージョン。
mustなパッケージは以下に挙げるものとし、mustなパッケージを最もエネルギー使わずに導入を行うための手順をかんたんに記すことにする。

  • numpy
  • scipy
  • pandas
  • matplotlib
  • scikit-learn
  • IPython notebook

リポジトリのインストール

# yum install epel-release

python3.xのインストール

yum list available | grep pythonpythonのversion確認する。
今回はpython3.4を以下のコマンドで導入する。

# yum install python34 python34-devel

これでpython3.4がインストールされる。

pip3の設定

# wget https://bootstrap.pypa.io/get-pip.py
# python3.4 get-pip.py

mustライブラリの導入

numpyの導入

http://stackoverflow.com/questions/18732250/installing-numpy-on-amazon-ec2 に記載がある通り、

Numpyのインストールには以下が必要。

そのため、以下の通りパッケージをインストールして、numpyをインストールする。

# yum install gcc-gfortran blas-devel lapack-devel 
# pip3 install numpy

scipyの導入

そのままscipyを導入しようとすると、以下のエラーメッセージが出力される。

  sh: g++: コマンドが見つかりません

よって、gcc-c++をインストールして、scipyをインストールする。

# yum install gcc-c++
# pip3 install scipy

pandasの導入

とくに依存はなくインストール可能。

# pip3 install pandas

matplotlibの導入

そのままmatplotlibを導入しようとすると、以下のエラーメッセージが出力される。

* The following required packages can not be built:
* freetype png

よって、freetype-develとlibpng-develをインストールして、matplotlibをインストールする。

# yum install freetype-devel libpng-devel
# pip3 install matplotlib

scikit-learnのインストール

普通にpipでインストール可能。

# pip3 install scikit-learn

IPython notebookのインストール

普通にpipでインストール可能。

# pip3 install ipython
# pip3 install ipython[noteboook]