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 currently works with Python 3.8 and greater.

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 a copy of the MeCab library, but not a 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

In order to use MeCab, you must install a dictionary. There are many different dictionaries available for MeCab. These UniDic packages, which include slight modifications for ease of use, are recommended:

  • unidic: The latest full UniDic.
  • unidic-lite: A slightly modified UniDic 2.1.2, chosen for its small size.

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 an actively maintained dictionary
  • pymecab-ko is a wrapper of the Korean MeCab fork mecab-ko based on mecab-python3
  • 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.11.dev5.tar.gz (78.7 kB view details)

Uploaded Source

Built Distributions

mecab_python3-1.0.11.dev5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (591.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.11.dev5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (568.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.11.dev5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (591.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.11.dev5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (569.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.11.dev5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (588.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.11.dev5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (567.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.11.dev5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (581.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.11.dev5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (560.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.11.dev5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (581.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.11.dev5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (560.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.11.dev5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (577.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.11.dev5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (555.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

File details

Details for the file mecab_python3-1.0.11.dev5.tar.gz.

File metadata

  • Download URL: mecab_python3-1.0.11.dev5.tar.gz
  • Upload date:
  • Size: 78.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for mecab_python3-1.0.11.dev5.tar.gz
Algorithm Hash digest
SHA256 16a5a879d184d5bfcfb93df66c3084e270a6d3b7ae0d1cc17c1f07a19852edc1
MD5 41f1314dd5a4d49e1897be31ba7f92b4
BLAKE2b-256 00275a4aa560421bcd064c8a3eeb675e631fb2b261c4b42e7e4c25a840d3417a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5.tar.gz:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 964f186fda84aa50c276dceb7812beae88b73d718b55b8db8a4ef0aff4970a64
MD5 b6438d3f7e8c72008a7e9778ab55c07a
BLAKE2b-256 3db677eeaed4f10fdffe8cbe81020249dc4c3bd2e8d4c3ac4f9e5977a09b5847

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 728ce698a8ac88700592ee6c8706e31168f40a9c67f9a9fe8c4a8a15fead1831
MD5 740498048f6312ee1c233dd602724c79
BLAKE2b-256 696809deccccad436a654017b54451cc3b491361920655a2ed9ba72fcd34f7ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3b2a120634fad4ae7c383cafb4b6d840807424a3424880da077bd249890964fb
MD5 788ab561fec95c778cac64cd33562c83
BLAKE2b-256 f3fca99793ccc205538284acd75acbbc8e7ac24cb92b36c220f0986e65b18248

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b063533489f92a61be1709f9ff1ffc23123a44b18664c7932ca3134c3e742354
MD5 60014eb15780d85aa3ed7a20be3ed425
BLAKE2b-256 4ff89b85d7b60c864e142e02f6a19c8fe422eb3a6ec06b3deaae7e2c1d0ac158

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b0e7432553529bffa4bd5d28274abd9b77d72fa3da57a00ceb09680b75e3a3a6
MD5 2efb6a758e87d6118824e2c0c78c0e8c
BLAKE2b-256 2ad5687397641bfa05574a4b720e0c8eb32101f30cae4e8efa782e6d14bceee6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 384551ad922779020b2fd804e2b719eea26996b455a232964e13cfc773dd3d1f
MD5 854338abef16bf1e2ae76c5cc56c5c51
BLAKE2b-256 5c5c118d3441d360f6d4bfe56e621204f8292dae94cc6dc7559d83f9ab7ac0c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 66e6daacc3d8369bac3e6aacc535ecdd69c5f2137b4decde42121092849c3341
MD5 132d0ee7bad7e6f994cd564a91305eb9
BLAKE2b-256 3dcc68ed17d708f4055f8d66ed69928d9b84ec44df71f9b5920866c73b2be18b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6ed58f0247393adc673b24f312d862cec962f61f8b6a23fb3bce9ab5a26a7ae1
MD5 4689ecb5aee1ec90ccd1ed1cc2790a39
BLAKE2b-256 ba9a09a4fe04fba6c47afd85844a9bce03eaa7fa8a6cd38cd368c7333b125b74

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c3e8b1ac08ebcb4ddb6fd9a893806256a483629a0c06b3841342b4a05b2cf05
MD5 398139fa10e47b45ab17b1a1fd2dda7b
BLAKE2b-256 89c5f6fcd8d49cf4879f1d9b2f3c34c27d98069aef2fe6493e5e86fdc91c43ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8b3e623d58a60403394628c163ca3da6a74d639587f6dab715de9c34845fada7
MD5 e67719bc8de46b329910ea3fcfcfa420
BLAKE2b-256 96913cccc9a5157ae67c4c94ee16812b037b590415b35efa8a664032a36bd4e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aced2ac3e09744eb58eafb39fc69c89c4e11d47e68a6d8d7709d090f0dafec81
MD5 8a8a857ca87121f833e23ee9843058ec
BLAKE2b-256 626746be3ccca24038c8a21ef4d5273d61a7210774282d4165f61bfb9e26f647

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mecab_python3-1.0.11.dev5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ab81491d589738bb47ede4438572e3016a7e1e638e15c2b02634859695ce43d2
MD5 93b497f2535a84ae6c6376ad50624754
BLAKE2b-256 9eeffe9293c8ae677173bf1a39ecdd3d71adbe7180efe0a3d8526cca1c0d2b6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: manylinux.yml on polm/mecab-python3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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