SamuraiT / mecab-python3

:snake: mecab-python. you can find original version here:http://taku910.github.io/mecab/
https://pypi.python.org/pypi/mecab-python3
Other
539 stars 51 forks source link

cannot importnameMeCab'from partially initialized module 'MeCab' #102

Closed hakusetsu1995 closed 4 months ago

hakusetsu1995 commented 5 months ago

I installed MeCab through

mecab_python3-1.0.9-cp312-cp312-win32.whl 

and got this error

>>> import MeCab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\my python\Lib\site-packages\MeCab\__init__.py", line 10, in <module>
    from . import _MeCab
ImportError: cannot import name ' **_MeCab**'  from partially initialized module 'MeCab' (most likely due to a circular import) (D:\my python\Lib\site-packages\MeCab\__init__.py)

How can I fix it?

python3.12.3(32bit) Windows11

polm commented 5 months ago

Circular imports are usually caused by having a file named mecab.py in your current working directory. Do you have a file like that? Also, to be clear, are you using the REPL, or are you running code from a file?

hakusetsu1995 commented 5 months ago

Thank you for your reply. There is no file namedmecab.py, I installed MeCab through mecab_python3-1.0.9-cp312-cp312-win32.whl, and I'm using IDLE to run import MaCab. mecab

polm commented 5 months ago

Hm, I'm not really sure what the cause would be then. I checked my records and I've never seen this issue except due to problems with source files with the same name. Here are some things to check:

Example simple code:

import MeCab

tagger = MeCab.Tagger()
print(tagger.parse("pythonが大好きです"))
polm commented 4 months ago

Closing due to lack of response, but feel free to follow up if you can provide more details.