Skip to content

Instantly share code, notes, and snippets.

@dogrunjp
Created August 5, 2016 17:59
Show Gist options
  • Save dogrunjp/da14d4fb1ecc17128e035dd63e41a8dd to your computer and use it in GitHub Desktop.
Save dogrunjp/da14d4fb1ecc17128e035dd63e41a8dd to your computer and use it in GitHub Desktop.
macでpyenv virtualenvを使ってテキストマイニングの環境を作るさいのMecab関連のインストール手順。Python3にするなら素直にpip installしたほうが良いという結果に。

Mac+Python環境のMecabセットアップ

pyenv virtualenv環境(python3)にMecabのpythonバインディングをpipインストールする

Mecabと辞書のインストールはbrew installでOK

$ brew install mecab
$ brew install mecab-ipadic

PythonでMecabを利用する

ただしPythonバインディングをダウンロードしてpipインストールしようとすると、一部ライブラリが未対応のためエラーが起きる

$ wget https://mecab.googlecode.com/files/mecab-python-0.996.tar.gz
$ pip install mecab-python-0.996.tar.gz 

~ AttributeError: 'module' object has no attribute 'split'

string.splitがpython3で使えなくなっているからとのこと。

Python3でMecab

pyenv環境でこれを修正してmake installするよりvirtualenv内でpip install できればその方が楽なのだが…

$ pip install mecab-python3

インストールできた模様

Mac OSX 10.11 Python3.5+Mecabインストールメモ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment