1.事前準備
sudo yum groupinstall "Development Tools"
yum install mlocate
yum install openssl-devel
yum install bzip2-devel
yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite3 sqlite-devel openssl-devel
yum install gcc gcc-c++
2. Amazon Linux Python3 インストール
こちらを参考にpyenvをインストール
pyenv install 3.5.2
pyenv global 3.5.2
pyenv rehash
[ec2-user@ip-172-31-5-227 ~]$ python3 --version
Python 3.5.2
[ec2-user@ip-172-31-5-227 ~]$ pip3 --version
pip 8.1.1 from /home/ec2-user/.pyenv/versions/3.5.2/lib/python3.5/site-packages (python 3.5)
3. Mecab インストール
wget https://mecab.googlecode.com/files/mecab-0.996.tar.gz
tar xvzf mecab-0.996.tar.gz
cd mecab-0.996
./configure
make
make check
sudo make install
cd ../
wget https://mecab.googlecode.com/files/mecab-ipadic-2.7.0-20070801.tar.gz
tar xvzf mecab-ipadic-2.7.0-20070801.tar.gz
cd mecab-ipadic-2.7.0-20070801
./configure -with-charset=utf-8 –enable-utf8-only
make
sudo make install
cd ../
4. mecab-ipadic-NEologd インストール
git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git
xz -dkv mecab-ipadic-neologd/seed/mecab-user-dict-seed.*.csv.xz
fname=`find mecab-ipadic-neologd/seed/ -name *.csv`
fullname=`pwd`/$fname
/usr/local/libexec/mecab/mecab-dict-index -d /usr/local/lib/mecab/dic/ipadic -u mecab-user-dict-seed.dic -f utf-8 -t utf-8 $fullname
vi /usr/local/etc/mecabrc
userdic = /home/ec2-user/mecab-user-dict-seed.dic
5. Python用のモジュールインストール
pip3 install --upgrade pip
pip3 install boto
pip3 install pysqlite
pip3 install bz2file
pip3 install Cython
pip3 install gensim
pip3 install inflect
pip3 install mecab-python3
pip3 install nltk
pip3 install numpy
pip3 install oauthlib
pip3 install pip
pip3 install prettyprint
pip3 install print
pip3 install requests
pip3 install requests-oauthlib
pip3 install scipy
pip3 install setuptools
pip3 install six
pip3 install smart-open
pip3 install tweepy
pip3 install wheel
pip3 install word2vec
6.おまじない+起動
export LD_LIBRARY_PATH=/usr/local/lib
[ec2-user@ip-172-31-10-197 ~]$ python3
Python 3.5.2 (default, Jul 25 2016, 05:54:24)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import MeCab
7. メモ
ついでにこちらにしたがってS3バケットをマウントします。
※その際に、S3側では認証済みユーザーのアクセス許可設定をするのを忘れずに。