Install Numpy, Schipy, Matplotlib and etc. on Amazon Linux AWS-ec2 for Python3

Installing NumPy, SciPy, Matplotlib, pandas, scikit-learn and pillow for Python 3.4 on Amazon Linux

You must always specify full paths for python3, pip3 and easy_install-3.4. You can tell a full path by the command, which <file or directory>
常にpython3, pip3, easy_install-3,4はフルパスを指定してください。whichコマンドでフルパスがわかります。

Always use pip3 to install for python 3.
Python 3にライブラリをインストールするには常にpip3を使うこと

About my AWS and Python

$ aws --version
aws-cli/1.6.6 Python/2.6.9 Linux/3.14.25-23.45.amzn1.x86_64

$ python3 --version
Python 3.4.2

Download and instal easy_install

$ cd /usr/local/src
$ sudo wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
$ which python3 # check the full path to python3
/usr/local/bin/python3
$ sudo /usr/local/bin/python3 ez_setup.py

Check easy_install for Python 3.4 installed

Insatall pip for python 3

$ which easy_install-3.4 # check the full path to easy_install 3.4
/usr/local/bin/easy_install-3.4

$ sudo /usr/local/bin/easy_install-3.4 pip

$ which pip3
/usr/local/bin/pip3
$ pip3 --version
pip 1.5.6 from /usr/local/lib/python3.4/site-packages (python 3.4)

Install NumPy for python 3

$ sudo /usr/local/bin/pip3 numpy
$ # also, sudo /usr/local/bin/easy_install-3.4 numpy works fine


Install LAPACK and BLAS

sudo yum install -y lapack-devel blas-devel

Install SciPy for python3

You may need install BLAS and LAPACK on your LINUX , not on  Python. So you do not need specify the python version)

$ sudo yum install blas-devel lapack-devel

$ sudo /usr/local/bin/pip3 scipy

when you fail with the error,
"virtual memory exhausted: Cannot allocate memory",
try the below

$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
$ sudo /sbin/mkswap /var/swap.1
$ sudo /sbin/swapon /var/swap.1

$ sudo /usr/local/bin/pip3 scipy

$ sudo swapoff /var/swap.1
$ sudo rm /var/swap.1


Install Matplotlib

You will install freetype version 2.4 or more and png.

$ sudo apt-get install libpng-devel

$ wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz
$ tar xzvf freetype-2.5.3.tar.gz
$ cd freetype-2.5.3
$ ./configure
$ make
$ sudo make install

$ /usr/local/bin/pip3 install matplotlib


Install PIL (Python Image Library)

$ sudo /usr/local/bin/pip3 install pillow

Install Pandas

$ sudo /usr/local/bin/pip3 install pandas 


Install scikit-Learn

$ sudo /usr/local/bin/pip3 install scikit-learn

Install SymPy

$ sudo /usr/local/bin/pip3 install sympy


Install PuLP

$ sudo /usr/local/bin/pip3 pulp

Install Beautiful Soup 4

$ sudo /usr/local/bin/pip3 install beautifulsoup4


Install lxml

$ sudo yum -y install libxslt-devel libxml2-devel gcc python-devel
$ sudo pip install lxml

Install twitter

$ sudo pip install twitter


Install oauth

$ sudo pip install aouth

Install iPython

$ sudo /usr/local/bin/pip3 ipython

Install boto

$ sudo /usr/local/bin/pip3 boto

Finally, check your libraries installed

$ /usr/local/bin/pip3 freeze
Pillow==2.6.1
PuLP==1.5.6
beautifulsoup4==4.3.2
boto==2.34.0
ipython==2.3.1
lxml==3.4.1
matplotlib==1.4.2
nose==1.3.4
numpy==1.9.1
oauth==1.0.1
pandas==0.15.2
pyparsing==2.0.3
python-dateutil==2.3
pytz==2014.10
scikit-learn==0.15.2
scipy==0.14.0
six==1.8.0
sympy==0.7.6
twitter==1.15.0



前回記事 (Previous article about installing python3 on Amazon Linux):

参考記事 Bibliography

コメント

  1. 私にとって非常に役に立つエントリでした。執筆ありがとうございました。

    返信削除
    返信
    1. しおりさん,ありがとうございます.今だったらAnaconda使ってPythonを導入したほうが,依存性や,バージョン管理などが楽かもしれません.

      削除

コメントを投稿

人気の投稿