LoginSignup
3
3

More than 5 years have passed since last update.

CircleCIでmecab-pythonをインストールする

Last updated at Posted at 2015-02-02

背景

過去にCentOS,OSXでmecab-pythonのインストールのチャレンジをしてうまく行った。
しかし、今回はCircleCI。CircleCIはUbuntu上で動くため、やっぱり環境が違うとうまく動きませんでした。キモは、標準でインストールされているmecabパッケージを消してソースからインストールすることです。mecabパッケージを入れたまま、mecab-pythonのbuildをするとコンパイルできずに失敗します。

設定手順

インストールスクリプト

$ vi install_mecab.sh

install_mecab.sh

#!/bin/bash

# Remove mecab
sudo apt-get remove mecab

# Install mecab
cd /var/tmp
curl -O https://mecab.googlecode.com/files/mecab-0.996.tar.gz
tar zxfv mecab-0.996.tar.gz
cd mecab-0.996
./configure
make
sudo make install

# load mecab.so
sudo sh -c "echo '/usr/local/lib' >> /etc/ld.so.conf"
sudo ldconfig

# Install mecab-ipadic
cd /var/tmp
curl -O https://mecab.googlecode.com/files/mecab-ipadic-2.7.0-20070801.tar.gz
tar zxfv mecab-ipadic-2.7.0-20070801.tar.gz
cd mecab-ipadic-2.7.0-20070801
./configure --with-charset=utf8
make
sudo make install

# Install mecab-python
pip install https://mecab.googlecode.com/files/mecab-python-0.996.tar.gz

CircleCIの設定

circle.yml

dependencies:
  override:
    - bash ./install_mecab.sh

おまけ

pipのrequirements.txtを使ってmecab-pythonをインストールする場合

requirements.txt

https://mecab.googlecode.com/files/mecab-python-0.996.tar.gz

※ 通常は、requests==2.3.0等と記入するところを、tar.gz指定できます。

circle.yml

dependencies:
  override:
    - pip install -r ./requirements.txt
3
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3