Make MeCab available from Python3

I couldn't find a way to use MeCab from Python3 by searching the Web, so I managed to do it myself. Here is a summary of the notes before making it available.

Problems and solutions

I was experiencing the following issues:

This can be resolved by applying two of the issues on the Google Code MeCab page. Support for Python3 is possible only by modifying mecab-python. However, if you do not fix the bug in MeCab itself, it will be buggy in parsing when used on Python. Therefore, MeCab itself is also installed and used by applying the patch and newly building it.

Operations performed in this environment

The URL of the patch I used had a weird token, so I wrote a link to Issue instead. Therefore, please obtain the patch at the link destination using a browser. Also, g ++ and python3-dev are required in advance.

$ wget https://mecab.googlecode.com/files/mecab-0.996.tar.gz $ tar -zxvf mecab-0.996.tar.gz $ wget request_type.patch (get at link) $ cd ~/mecab-0.996 $ patch -u < ../request_type.patch $ ./configure --enable-utf8-only $ make $ sudo make install

$ wget https://mecab.googlecode.com/files/mecab-ipadic-2.7.0-20070801.tar.gz $ tar -zxvf mecab-ipadic-2.7.0-20070801.tar.gz $ cd ~/mecab-ipadic-2.7.0-20070801 $ ./configure --with-charset=utf8 $ make $ sudo make install

$ wget https://mecab.googlecode.com/files/mecab-python-0.996.tar.gz $ tar -zxvf mecab-python-0.996.tar.gz $ wget MeCab.py (Get at link) $ wget MeCab_wrap.cxx (Get at link) $ mv MeCab.py mecab-python-0.996/ $ mv MeCab_wrap.cxx mecab-python-0.996/ $ cd ~/mecab-python-0.996 $ vi setup.py

Apply the fix for python3 (http://anond.hatelabo.jp/20121113070853) return string.split (cmd1 (str)) return Rewrite to cmd1 (str) .split ().

$ python3 setup.py build $ sudo python3 setup.py install

important point

You cannot run mecab-python-0.996 / test.py after the installation is complete. The cause is because it is written in python2. Please check the operation after correcting it.

Recommended Posts

Make MeCab available from Python3
MeCab from Python
Make OpenCV3 available from python3 installed with pyenv
Make Opencv available in Python
Notes on using MeCab from Python
python / Make a dict from a list.
[Lambda] Make import requests available [python]
[Python] Make pip available on macOS
From Python to using MeCab (and CaboCha)
Make the morphological analysis engine MeCab available in Python 3 (March 2016 version)
sql from python
python> link> from __future__ import print_function> Make Python 3.X print () available in Python 2.X
Make DHT11 available on Raspberry Pi + python (memo)
I want to make C ++ code from Python code!
Make JSON into CSV with Python from Splunk
Use thingsspeak from python
Touch MySQL from Python 3
Operate Filemaker from Python
Use fluentd from python
Changes from Python 2 to Python 3.0
Make the library created by Eigen in C ++ available from Python with Boost.Numpy.
Python from or import
Use MySQL from Python
Use mecab with Python3
Run python from excel
Install python from source
Execute command from Python
Operate neutron from Python!
Use MySQL from Python
Operate LXC from Python
Manipulate riak from python
Force Python from Fortran
Use BigQuery from python.
Execute command from python
[Python] Read From Stdin
Use mecab-ipadic-neologd from python
Make a copy of a Google Drive file from Python
Collecting information from Twitter with Python (morphological analysis with MeCab)
The first step to getting Blender available from Python
Make anaconda environment available from command prompt on windows
Deep Python learned from DEAP
[Python] Morphological analysis with MeCab
Grammar features added from Python3.6
Cheating from PHP to Python
Make iPython available on OSGeo4W
Information obtained from tweet_id (Python)
OCR from PDF in Python
Run illustrator script from python
Use MySQL from Anaconda (python)
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Study from Python Hour4: Object-oriented ②
Query Athena from Lambda Python
Access Oracle DB from Python
Made python available on macOS
Study from Python Hour3: Functions
Make Cython available on Windows.
Make Puyo Puyo AI with Python
Start / stop GCE from python
Don't make test.py in Python!
Keyword extraction by MeCab (python)
Make a bookmarklet in Python