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 Distribution

mecab-python3-1.0.4.tar.gz (78.1 kB view details)

Uploaded Source

Built Distributions

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

mecab_python3-1.0.4-cp39-cp39-win_amd64.whl (511.1 kB view details)

Uploaded CPython 3.9Windows x86-64

mecab_python3-1.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (561.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (489.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

mecab_python3-1.0.4-cp39-cp39-macosx_10_14_x86_64.whl (281.0 kB view details)

Uploaded CPython 3.9macOS 10.14+ x86-64

mecab_python3-1.0.4-cp38-cp38-win_amd64.whl (511.1 kB view details)

Uploaded CPython 3.8Windows x86-64

mecab_python3-1.0.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (555.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (490.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

mecab_python3-1.0.4-cp38-cp38-macosx_10_14_x86_64.whl (281.1 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

mecab_python3-1.0.4-cp37-cp37m-win_amd64.whl (510.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

mecab_python3-1.0.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (554.0 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ ARM64

mecab_python3-1.0.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (488.5 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

mecab_python3-1.0.4-cp37-cp37m-macosx_10_14_x86_64.whl (281.0 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

mecab_python3-1.0.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (552.9 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ ARM64

mecab_python3-1.0.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (488.3 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.5+ x86-64

mecab_python3-1.0.4-cp36-cp36m-macosx_10_14_x86_64.whl (281.0 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file mecab-python3-1.0.4.tar.gz.

File metadata

  • Download URL: mecab-python3-1.0.4.tar.gz
  • Upload date:
  • Size: 78.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for mecab-python3-1.0.4.tar.gz
Algorithm Hash digest
SHA256 b150ad5fe4260539b4ef184657e552ef81307fbbe60ae1f258bc814549ea90f8
MD5 312e49f2f44c08b6797fbeba018dd3dd
BLAKE2b-256 5a90348cda0312df7ff25d57ca56560b6871be42e48a99b1ddc091f6f23e96cc

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 511.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for mecab_python3-1.0.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 445b4f5ee5674d85f6de2726ec28991801844ff71eb096129da5f5ba077d5a87
MD5 0ab278ce58df4a9eeeaca2369a58d789
BLAKE2b-256 9c726f938ad817899a35cd678846b3551fc24f5b2e0643af47df0dd8e9daf1ef

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 178b632b717e3249054a7ad4c0fbc60ce8493d357afa7673d535ffa11e45eaba
MD5 b8411609132150c1e21ae2b9cef031b4
BLAKE2b-256 ab314f9135d7a876c236bf7951f2d0e8d1063f285c24ed332300909d6b20f34d

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fbfad60261ad3b9390b8615528fc013302a3e8febba220f799216c1a1154ee7e
MD5 e7bcbebce1c92a46305c9ea74c17761d
BLAKE2b-256 d688cc40d4b959adfea1c0e3433b6c7655162c0692e3593156e258a48b954a4d

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.4-cp39-cp39-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 281.0 kB
  • Tags: CPython 3.9, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for mecab_python3-1.0.4-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 dcd62ebf2eecde1263119b92ff5379a046bb8231cb999fafda00f0925dfcb67e
MD5 3caf0d59db9db5d56a40dcd78d649cfc
BLAKE2b-256 7460a0a887f8349d00b9a5357864344a2c6236469328218c6ee96971f6337c12

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 511.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for mecab_python3-1.0.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 96d9e8c098401fb4b5bd32258f4952f3b22cdb30ab291f5ff82eae1d0941cbed
MD5 06fcaf7fd9704582bf2650f087fc58dc
BLAKE2b-256 5bc8285090231f31570487e474699a9cce3655c88085f909e9c36be0222fb7bc

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 221256b84be0ee29dc8fa450210236b40707b9d63cfc70de5102d2531622d062
MD5 13593c73f5e47680c3610d182030f663
BLAKE2b-256 1003ed9409ce51bc159523309757bcdccac5eafbc63799f0b2abbf569da0d8f2

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 de39b82f44d97fc0fd636644ad14c9662f51afcd73775379d5a8b1eb20ee85a6
MD5 c53f96f58588e356ccea4c242a178f74
BLAKE2b-256 3814947c18d87783ffb35d95268df7add0a11da4fb17ac19f308af5bfc99398b

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.4-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 281.1 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for mecab_python3-1.0.4-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 18e14dfe3d8c66cfa1c9f49e3bc8ac480b79a433ec9e5b5d2c1fb73f36ec7c3e
MD5 493748f2055f0bfcbc4f3690d6ccf085
BLAKE2b-256 fce05f61d89da52d26f9edf410598e0c2c5c58590db7a831904b507e610765ea

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.4-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 510.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for mecab_python3-1.0.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d6ca73c0dec72038290faa6de17d57d771535eb47c22346e170dffcb82d696bb
MD5 43e885b59f3d99c5585bcc32d3f38f90
BLAKE2b-256 c767e5c7eb8ac5860329577504df19cdc8a8a60e0dd847dfd88c6e87421cd635

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 53b0b899ef03f364bfd7fa28f260ee1e893e4f47ff90a141a522709b892f0a4e
MD5 de92056a0d64d68657a3abe3a2cf8eb4
BLAKE2b-256 2f1602967a5f3686f2c74b71c02e87bbafc8d7d16b2d0d561524472cc4c5a44a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 52a789c708f8b89044236201eb03c7fe5517fad5210a9de2230c7d99a2a8c760
MD5 2529fb7e12524f03a80b944073d507c6
BLAKE2b-256 8b4a6ab07c8c166753282571ef3c51362a0fd8c00ff029c4f38c0a042184c32f

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.4-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 281.0 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.10

File hashes

Hashes for mecab_python3-1.0.4-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c1606b35df0136b3e9dc7add2e69d2c1151e69fd5675c0cde62d0b017b2319e7
MD5 a98a3d438243787681787b4c8dfe4a74
BLAKE2b-256 c8062007129dc7f3855a88a54908cdf72d9587564ace9301a9f2cdfdd15e43c8

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.4-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.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.8

File hashes

Hashes for mecab_python3-1.0.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 b149b51f0f62c9512d219c9e79c6db2eb66e70863a97eb412d8fc3ba7a25f351
MD5 d89df9ba7d1057005baf01a02afbe413
BLAKE2b-256 913c93ab72e83e23528c6d1685d1f510104804a52e2d5fabf6fbf2d5f7010bd8

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b2fbed960ef82f4192b31efd88af1f3c24cd1692b62720ed70d7e314a50f581e
MD5 91497f922cae7e9b510ceca9e1f5c151
BLAKE2b-256 e51a386d1b27bcc6b9285eb27d43892c9291b7c7cd2c3c593b9dccfe21e7a016

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cb6eb6cc47e3937a2edfaa9595dc2d165ed9f025e3a53bd0a5033a12fa6bcdcf
MD5 c6e3e6ec374af5931ea91b024620fd15
BLAKE2b-256 bcc8ecdee75274b4bf365f5aed9ce9548834f495652d27607e1be9465e654dad

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.4-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.4-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 281.0 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.13

File hashes

Hashes for mecab_python3-1.0.4-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 3c7e87c65160e5e4edb08cb80dbce50f4e711c53f45063321aab72ab2566ffe4
MD5 7e05da729bda61f9e3ddf815b40d10b5
BLAKE2b-256 cb6958a14f762f75e8c98312216b198862683d1b40aabdd180fb848835600518

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