buruzaemon / natto-py

natto-py combines the Python programming language with MeCab, the part-of-speech and morphological analyzer for the Japanese language.
BSD 2-Clause "Simplified" License
92 stars 13 forks source link

"from natto import MeCab" doesn't work #91

Closed shuntaroy closed 6 years ago

shuntaroy commented 8 years ago

From ver 0.8, from natto import MeCab doesn't work properly. However, it does from natto.mecab import MeCab.

Are there any change of the specification of the namespace?

buruzaemon commented 8 years ago

Thanks for reporting this.

Could tell me your platform and Python version?

Brooke@iPhone

2016/04/22 17:30$B!"(BShuntaro Yada notifications@github.com $B$N%a%C%;!<%8(B:

From ver 0.8, from natto import MeCab doesn't work properly. However, it does from natto.mecab import MeCab.

Are there any change of the specification of the namespace?

$B!=(B You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

shuntaroy commented 8 years ago

Thank you for your prompt reply.

I use Python 3.5.1 of Anaconda3-2.5.0 under pyenv, and installed natto-py via pip. When I try to import it by from natto import MeCab, I got ImportError: cannot import name 'MeCab'.

buruzaemon commented 8 years ago

Thanks for letting me know. I will have a look at this tonight.

Brooke@iPhone

2016/04/22 18:11$B!"(BShuntaro Yada notifications@github.com $B$N%a%C%;!<%8(B:

Thank you for your prompt reply.

I use Python 3.5.1 of Anaconda3-2.5.0 under pyenv, and installed natto-py via pip. When I try to import it by from natto import MeCab, I got ImportError: cannot import name 'MeCab'.

$B!=(B You are receiving this because you commented. Reply to this email directly or view it on GitHub

buruzaemon commented 8 years ago

Some notes on the investigation so far:

  1. In the case of no environment manager, this problem is not reproducible (Pythons 2.7, 3.3, 3.4 and 3.5).
  2. In the case of Anaconda's conda environment manage, this problem is still not reproducible.

I suspect that this might have something to do with how pyenv works. Will have a look at pyenv next...

shuntaroy commented 8 years ago

Thanks for letting me to know the progress. Now I've come up with another possibility.

Just before I encounter this problem, I wrongly installed another "natto" library via pip instead of your "natto-py". However, I installed "natto-py" after I uninstalled the "natto" library. So I didn't believe this may cause problem. But I also try to check the problem reproducibility.

shuntaroy commented 8 years ago

I found reproducibility of this issue under the situation where natto package installed wrongly, even if natto uninstalled successfully. Especially, it seems to be reproduced when natto package is imported at least once. In other words, it seems not to be reproduced if natto have never been imported. I don't know the detail of pip, but it may still store some cache of uninstalled namespaces.

I'm familiar to ruby gem version of your natto, so I sometimes mistake to install python version of that in pip install natto when I reconstruct my python environments.

buruzaemon commented 8 years ago

Apologies for not replying sooner. And thank you, @shuntaroy.

I think I need to reconsider how this library should be imported. It is unfortunate that the namespace natto has already been taken, and thus is causing confusion.

I will continue to treat this issue as a bug, and come up with a new package naming.

shuntaroy commented 8 years ago

That's a shame if you change this fancy package name. I really like your idea of the combination of natto and mecabu.

Besides my personal preference, I believe there are some reasons that you don't have to change the package name:

Rather it might be good to note this problem and its solution (which I report in the first post) in README or your helpful Wiki of this repo.

P.S. I really thank your nice package that enables us to easily deal with MeCab in Python and Ruby. It helps my researches and app development. Your instructions in wiki is informative too. Thank you so much.

buruzaemon commented 8 years ago

Thanks for sharing your opinions and feedback with me, @shuntaroy.

I was aware of the other natto package, which came before natto-py, and back then I thought the naming would not be a problem.

However, I think I might need to honor the original natto package's namespace, and choose another one like natto_py or something. I am afraid that the name I chose is actually the cause of some confusion. I will think more about whether I should change this package name.