mecab-python with Ubuntu12.04 LTS
環境確認
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
準備としてひと通りのビルドパッケージをインストール
$ sudo apt-get install build-essential
これをインストールしとかないと以下のようなエラーが発生する。
checking if g++ supports GCC native atomic operations (optional)... no
checking if g++ supports OSX native atomic operations (optional)... no
checking if g++ environment provides all required features... no
configure: error: Your compiler is not powerful enough to compile MeCab.
MeCabのインストール
$ wget http://mecab.googlecode.com/files/mecab-0.996.tar.gz
$ tar xzvf mecab-0.996.tar.gz
$ cd mecab-0.996/
$ ./configure --enable-utf8-only
$ make
$ sudo make install
辞書のインストール
$ wget http://mecab.googlecode.com/files/mecab-ipadic-2.7.0-20070801.tar.gz
$ tar xzvf mecab-ipadic-2.7.0-20070801.tar.gz
$ cd mecab-ipadic-2.7.0-20070801/
$ ./configure --with-charset=utf8
$ make
/usr/local/libexec/mecab/mecab-dict-index: error while loading shared libraries: libmecab.so.2: cannot open shared object file: No such file or directory
上記のエラーが出るので以下で対応する。
$ sudo vim /etc/ld.so.conf
include /usr/local/lib
を追加する。
$ sudo ldconfig --->(更新)
$ make
$ sudo make install
mecab-pythonをインストール
$ sudo aptitude install python-dev
$ wget http://mecab.googlecode.com/files/mecab-python-0.996.tar.gz
$ tar xzvf mecab-python-0.996.tar.gz
$ cd mecab-python-0.996/
$ python setup.py build
$ sudo python setup.py install
※mecabとバージョンをあわせましょう。
合わせないと以下のようなエラーが出ます。
MeCab_wrap.cxx: In function ‘const mecab_node_t* mecab_node_t_begin_node_list(mecab_node_t*, size_t)’:
MeCab_wrap.cxx:3083:3: warning: control reaches end of non-void function [-Wreturn-type]
error: command 'gcc' failed with exit status 1
参考:
Ubuntu のデフォルトでは gcc でコンパイルできないので build-essential を入れておく
mecab google code
Rによるテキストマイニング入門