Skip to main content

Python wrapper for the MeCab morphological analyzer for Japanese

Project description

This is a Python wrapper for the MeCab morphological analyzer for Japanese text. It works with Python 3.6 and greater; if you need to use Python 2.7, use v1.0.2.

Note: If using MacOS Big Sur, you'll need to upgrade pip to version 20.3 or higher to use wheels due to a pip issue.

issueを英語で書く必要はありません。

Note that Windows wheels require a Microsoft Visual C++ Redistributable, so be sure to install that.

Basic usage

>>> import MeCab
>>> wakati = MeCab.Tagger("-Owakati")
>>> wakati.parse("pythonが大好きです").split()
['python', 'が', '大好き', 'です']

>>> tagger = MeCab.Tagger()
>>> print(tagger.parse("pythonが大好きです"))
python  python  python  python  名詞-普通名詞-一般
                        助詞-格助詞
大好き  ダイスキ        ダイスキ        大好き  形状詞-一般
です    デス    デス    です    助動詞  助動詞-デス     終止形-一般
EOS

The API for mecab-python3 closely follows the API for MeCab itself, even when this makes it not very “Pythonic.” Please consult the official MeCab documentation for more information.

Installation

Binary wheels are available for MacOS X, Linux, and Windows (64bit) are installed by default when you use pip:

pip install mecab-python3

These wheels include an internal (statically linked) copy of the MeCab library, but not dictionary. In order to use MeCab you'll need to install a dictionary. unidic-lite is a good one to start with:

pip install unidic-lite

To build from source using pip,

pip install --no-binary :all: mecab-python3

Dictionaries

There are many different dictionaries available for MeCab. These UniDic packages, which include slight modifications for ease of use, are recommended:

  • unidic: The full UniDic 2.3.0.
  • unidic-lite: The older, much smaller, but not much less useful 2.1.2.

The dictionaries below are not recommended due to being unmaintained for many years, but they are available for use with legacy applications.

For more details on the differences between dictionaries see here.

Common Issues

If you get a RuntimeError when you try to run MeCab, here are some things to check:

Windows Redistributable

You have to install this to use this package on Windows.

Installing a Dictionary

Run pip install unidic-lite and confirm that works. If that fixes your problem, you either don't have a dictionary installed, or you need to specify your dictionary path like this:

tagger = MeCab.Tagger('-r /dev/null -d /usr/local/lib/mecab/dic/mydic')

Note: on Windows, use nul instead of /dev/null. Alternately, if you have a mecabrc you can use the path after -r.

Specifying a mecabrc

If you get this error:

error message: [ifs] no such file or directory: /usr/local/etc/mecabrc

You need to specify a mecabrc file. It's OK to specify an empty file, it just has to exist. You can specify a mecabrc with -r. This may be necessary on Debian or Ubuntu, where the mecabrc is in /etc/mecabrc.

You can specify an empty mecabrc like this:

tagger = MeCab.Tagger('-r/dev/null -d/home/hoge/mydic')

Using Unsupported Output Modes like -Ochasen

Chasen output is not a built-in feature of MeCab, you must specify it in your dicrc or mecabrc. Notably, Unidic does not include Chasen output format. Please see the MeCab documentation.

Alternatives

  • fugashi is a Cython wrapper for MeCab with a Pythonic interface, by the current maintainer of this library
  • SudachiPy is a modern tokenizer with a maintained dictionary, though it's slower than MeCab
  • KoNLPy is a library for Korean NLP that includes a MeCab wrapper

Licensing

Like MeCab itself, mecab-python3 is copyrighted free software by Taku Kudo taku@chasen.org and Nippon Telegraph and Telephone Corporation, and is distributed under a 3-clause BSD license (see the file BSD). Alternatively, it may be redistributed under the terms of the GNU General Public License, version 2 (see the file GPL) or the GNU Lesser General Public License, version 2.1 (see the file LGPL).

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mecab_python3-1.0.5a1-cp39-cp39-win_amd64.whl (500.7 kB view details)

Uploaded CPython 3.9Windows x86-64

mecab_python3-1.0.5a1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (489.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

mecab_python3-1.0.5a1-cp39-cp39-macosx_10_15_x86_64.whl (282.9 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

mecab_python3-1.0.5a1-cp38-cp38-win_amd64.whl (500.8 kB view details)

Uploaded CPython 3.8Windows x86-64

mecab_python3-1.0.5a1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (490.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

mecab_python3-1.0.5a1-cp38-cp38-macosx_10_14_x86_64.whl (282.8 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

mecab_python3-1.0.5a1-cp37-cp37m-win_amd64.whl (500.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

mecab_python3-1.0.5a1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (488.8 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

mecab_python3-1.0.5a1-cp37-cp37m-macosx_10_14_x86_64.whl (282.8 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

mecab_python3-1.0.5a1-cp36-cp36m-win_amd64.whl (510.7 kB view details)

Uploaded CPython 3.6mWindows x86-64

mecab_python3-1.0.5a1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (488.7 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.5+ x86-64

mecab_python3-1.0.5a1-cp36-cp36m-macosx_10_14_x86_64.whl (282.8 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file mecab_python3-1.0.5a1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.5a1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 500.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for mecab_python3-1.0.5a1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 38057e350e7e61aced50bc83a423904652f72621bdb20c2e5268491d59b1a4ae
MD5 43fc6961693d9c5741eeff364e46884d
BLAKE2b-256 b62df498ea03ec407497e7d53ebfa35573246f2b88f6ab50cb5f58b03287316c

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.5a1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 82f26920e29c16090c68b4b4c1d74616ef2118710da11bdce7cadbb63d5f06f8
MD5 596883c7562dfa49b0e30f77e8759f6c
BLAKE2b-256 d7665a2ebf096095adfbc76779db708c1507a3785a39fd0866b699ec39be9950

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.5a1-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 282.9 kB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for mecab_python3-1.0.5a1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 131a7fa774d1eafc269fbbc1cfbcd09fe268555fb4ae6379983b0604f5427faa
MD5 6c83bca2738663f22a167859f13ef5f7
BLAKE2b-256 cb5aad2e9d958e46541055fdb1dd475aa03114ebd54aa10cb2abc33a35200f30

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.5a1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 500.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for mecab_python3-1.0.5a1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 eee4cc5d4aba7086760bb5c40e2a3f893c7ab2f10f07cc8949fb86f3924327bc
MD5 d6178c30322d442038327842d246f7f2
BLAKE2b-256 f2c3e6450a8af75661b9ecbfb48fa6d44e74ad20fb8324e8c0c33d8cf42688ea

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.5a1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 36493e5044dd0028ac3ac15e7d9a9d2449965bbf4516ec2c6a0500a6164265f8
MD5 2e06cea3e3b7364e0f4c6c7a0f6265e8
BLAKE2b-256 234e10560ef86e48ffff5d0a998e70f1950f28dcbcd4fc4bfd32cb004e1268df

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.5a1-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 282.8 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for mecab_python3-1.0.5a1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b50ab9cf1102d4f361f0c69f7b648f1c7657bf5a99c19022be16fde7e1ed2331
MD5 c632133299e6ed395fd91df19043099e
BLAKE2b-256 28b1e22a81afc2834c3d56f7f79713fcd97d23b2b328a44d605e75e66355931d

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.5a1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 500.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for mecab_python3-1.0.5a1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 eba8eb108b3996fe23307ab53596076187192f3469fd36b0c0a691609f65bf5c
MD5 555e2ce1adea979e0c000d6ed0774205
BLAKE2b-256 251067f8d3933a42b487736ae48a378f49585be7540a7c99b34b7cc8f036d6c6

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.5a1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 444b2798be6edf220e529fd6475414d15f48ba128c79553126224fbb8bf458c6
MD5 d4eb49ec60b78d5512982f52a5a7861d
BLAKE2b-256 3f36239ec1b5c9cfb4efa74e977c0ef4d901823583821587d005538b7d65b3b9

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.5a1-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 282.8 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for mecab_python3-1.0.5a1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b9a227ea7df996b63c9823421805296c0dda2532421d6fe04734a549c64c6d8b
MD5 2cd2f1910151cfc2385e274d96377dad
BLAKE2b-256 a5b5695e2e9a84824cca026e0be5fb9c0378f74a9d06253173373f566befd1f6

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.5a1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 510.7 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.8

File hashes

Hashes for mecab_python3-1.0.5a1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d632c07e17943aafb462015d29f070a91cbd0827c3b390bf896b3c5aa4efa97c
MD5 677ba13e4c5a8ba7dc7318cc35e4baa4
BLAKE2b-256 b2cd7b272ebb85a5346f41363550bd25b32b324d4708a028c35f7a1c1f03a44a

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.5a1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 62b2251ef286f691e16d35baca7c38a2e5ef6ba1c9e0e6fff8011b21a7412bb2
MD5 a00def6805f4fb1c6091be25aceb40ad
BLAKE2b-256 ba8f39dec6e6afbbb4b1a73ad3137567e5893dc35f73352b7130366f2ff13540

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.5a1-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.5a1-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 282.8 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15

File hashes

Hashes for mecab_python3-1.0.5a1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 858dbca1eecf767ba8450e0b20695fb395c6eb0b341a6bdcf674c4322c6ffc93
MD5 80aad51ef0a334b6dd6bc7534e5d7863
BLAKE2b-256 15fe0b4311fdc254814a7cad2fc3311fb763b6d9d7185d47201a7718c796a184

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page