After pip installing mecab-python3 on google colab, import mecab results in an error.
1. Install mecab body: Successful
! apt-get install mecab mecab-ipadic-utf8 libmecab-dev swig
2. Install mecab-python3: The latest version 0.8.2 will fail, so ver 0.8.0 designation succeeds.
!pip install mecab-python3 == 0.8.0
3. Import to Error
import mecab
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-58-71af23e59d14>in<module>()
---->1 import mecab
ModuleNotFoundError: No module named 'mecab'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either!pip or!apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Here is the Google colab notebook.
https://colab.research.google.com/drive/1Bm81uSoJQOyERAi0wDvrvZ-A-ex2-cbf
I am very sorry to trouble you, but I look forward to your warm guidance and encouragement.
python google-colaboratory
Problem 1
The macab import is in Pascal format, not lowercase.
import MeCab
Problem 2
mecab-python3
has a problem with the ver0.8 package.
·https://github.com/SamuraiT/mecab-python3/issues/11
For PyPI, it is ver0.7 (more likely it was returned): https://pypi.org/project/mecab-python3/
You don't need to install swig, I think you can install it in a traditional way.
! apt-get install libmecab-dev mecab-ipadic-utf8
! pip install mecab-python3
The library name has a different case. Try import MeCab
instead of import mecab
.
Note: Cite a sample program from https://pypi.org/project/mecab-python3/.
import MeCab
mecab=MeCab.Tagger("-Ochasen")
print(mecab.parse("I love python""))
© 2024 OneMinuteCode. All rights reserved.