PythonでMecabを使ってみる
// mecab本体
$ wget http://mecab.googlecode.com/files/mecab-0.99.tar.gz
$ tar -xzf mecab-0.99.tar.gz
$ cd mecab-0.99
$ ./configure --with-charset=utf8
$ make && sudo make install
// mecab-ipadic
$ wget http://sourceforge.net/projects/mecab/files/mecab-ipadic/2.7.0-20070801/mecab-ipadic-2.7.0-20070801.tar.gz/download
//$ tar -xzf mecab-ipadic-2.7.0-20070801.tar.gz
$ tar -xzf download
$ cd mecab-ipadic-2.7.0-20070801
$ ./configure --with-charset=utf8
$ make && sudo make install
$ wget http://mecab.googlecode.com/files/mecab-python-0.993.tar.gz
$ tar -xzf mecab-python-0.993.tar.gz
$ python setup.py build
$ sudo python setup.py install
それでpythonで
import MeCab
を実行してみたのだけれども。。。エラー。
>>> import MeCab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MeCab.py", line 25, in <module>
File "MeCab.py", line 17, in swig_import_helper
import _MeCab
ImportError: libmecab.so.2: cannot open shared object file: No such file or directory
そこで、
vim /etc/ld.so.confを実行して
/usr/local/lib
を追加する。
ldconfig
で更新して、
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MeCab
>>>
無事インストールできました。