Home>

You are trying to run a file that imports a mecab module.
I want to solve the problem that I get an error when I try to execute with a file even though Mecab can be used from the terminal.

Error message

When I try to execute a file that imports a mecab module, I get the following error:

$python sample.py
Traceback (most recent call last):
  File "sample.py", line 2, in<module>
    import Mecab
ModuleNotFoundError: No module named 'Mecab'
Applicable source code

When using mecab from the terminal

$mecab
Sunny  
Sunny Noun, General, *, *, *, *, Sunny, Halle, Halle
EOS
Supplemental information (FW/tool version etc.)
$mecab -v
mecab of 0.996


Python 3.6.0 :: Anaconda 4.3.0

  • Answer # 1

    Mecab is a command and has nothing to do with Python, so even if you can run mecab, you can't use modules with python.

    You must install mecab's Python binding module for Python.

    For Mac,pip install mecab-python3is fine.


    The package name of the Python binding module isMeCab.

    Useimport MeCabinstead of

    import Mecab.