Sumi
Sumi

Reputation: 55

Python mecab package import error on Windows 'not defined'

I am trying to install mecab on English OS Windows 10. I am using the command prompt and simply did;

pip install mecab

It looked like the package was installed;

Collecting mecab
Using cached mecab-0.996.3-cp39-cp39-win_amd64.whl (500 kB)
Installing collected packages: mecab
Successfully installed mecab-0.996.3

But then, if I go to python (by typing 'python' in the command line) and do;

import mecab

I get this error.

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mecab'

If I try to import MeCab.py file, I get;

ImportError: DLL load failed while importing _MeCab: The specified module could not be found.

I set PYTHONPATH in the environmental variables. No luck.

Upvotes: 3

Views: 2395

Answers (2)

Shrey
Shrey

Reputation: 36

Try for the following:

pip install mecab

Upvotes: 0

polm23
polm23

Reputation: 15623

The mecab package on pypi requires you to install MeCab separately if you are using a platform other than 32bit Python on Windows.

If you use mecab-python3 32bit Python on Windows is not supported, but for other platforms you do not need to install MeCab separately.

It looks like you are using 64bit Python so mecab-python3 would fix your issue.

Also rarely sometimes installs on Windows don't get included DLL files. I've never been able to figure out why this happens but it's usually some kind of Python configuration issue, often related to conda. Check if your site-packages directory with the MeCab package has a mecab.dll or similar file.

Upvotes: 3

Related Questions