🎉

MeCabの初期化に失敗するエラー

2023/08/10に公開

エラー内容

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/MeCab/__init__.py", line 133, in __init__
    super(Tagger, self).__init__(args)
RuntimeError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 22, in <module>
    analyzer = TweetAnalyzer('tweetdata.db')
  File "/Users/kitsune_yk/develop/kawwailab/generate-dramatic-images-by-location-keywords/utils/tf_idf.py", line 13, in __init__
    self.mecab = MeCab.Tagger("")
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/MeCab/__init__.py", line 135, in __init__
    raise RuntimeError(error_info(rawargs)) from ee
RuntimeError: 
----------------------------------------------------------

Failed initializing MeCab. Please see the README for possible solutions:

    https://github.com/SamuraiT/mecab-python3#common-issues

If you are still having trouble, please file an issue here, and include the
ERROR DETAILS below:

    https://github.com/SamuraiT/mecab-python3/issues

issueを英語で書く必要はありません。

------------------- ERROR DETAILS ------------------------
arguments: 
[ifs] no such file or directory: /usr/local/lib/mecab/dic/ipadic/dicrc
----------------------------------------------------------

解決方法

mecab-python 1.0以上で辞書ライブラリunidic-liteを別でインストールしないとだめらしい

下記コマンドを実行し、再度Python3 main.pyを実行

pip3 install unidic-lite

Discussion