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.dev8.tar.gz (78.7 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.11.dev8-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.dev8-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.dev8-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.dev8-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.dev8-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.dev8-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.dev8-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.dev8-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.dev8-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.dev8-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.dev8-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.dev8-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.dev8.tar.gz.

File metadata

  • Download URL: mecab_python3-1.0.11.dev8.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.dev8.tar.gz
Algorithm Hash digest
SHA256 059ca1f95b24783a7e8eac4699d186efdc639024a86e0585f205a555ddccaade
MD5 d97dd6e10d706dac17f605e40922d697
BLAKE2b-256 d16cfa159dc258a98c60c9195681b3e05e0db69b8a2a8a6fee4c292cf0cf1724

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8.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.dev8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 89543a346e54678cfb8013bb15e145ef14ded29c865cd059bd85a8ee9c8a7a48
MD5 d6b6ab9b983e80ebca7454e1bc8c3d29
BLAKE2b-256 6382334e19ad7c3811af0e15febb19b0c3d03645de9af383c0124314b1323048

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ff674ceb60de2129806735a285079a22bc4847df3b18a1237f6c32e4d0f26adb
MD5 065a74221ace0d0a4c116daa4264de8e
BLAKE2b-256 87e210d2b4be127116af686c7c7ca704a44801bf404735724e0ed1245f68bf10

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2bd975dd3292729aa503783b6e0c6482c323610468de37eff26b03993514cd1a
MD5 93f8dcb6d4873fb00ccdd273c9167c60
BLAKE2b-256 404acab12a743fe3377156cb620cf35d4148c4867a8cd9edab7d525d0be366e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9a4e2097a4c552ee904c6c7baaee982ca825134b1a20e5b033824fe08a30b7d2
MD5 a1358c07cbb26e60f858b16dbe9e2e4b
BLAKE2b-256 4910437eccb7cf01df4f93daf562f3b6709fe57f276f2e59b3613cbfcce5c0a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6851aa9d35bb8c9eef0fc8c5fd8f83c276d54f0b47166b59f8cbddc28ec8fabe
MD5 ec7454e6bf433060da8aff7c5e68eae8
BLAKE2b-256 1854aa5cc1d54f49f2660d610b64e84c3dc183f23a4a5388c8c88e6747425a1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6ab17cad68e4d95ea58ba4e63000fa028f9e1f401c7f3fe7c1dff475674dbb46
MD5 f7983cc98385c18925ef61a3fb2eae50
BLAKE2b-256 5f02b062612861dcbddcd614c8d100561eff728960c42c3ac8ab0636a234f125

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b67462574524eb5cd68ce0ef09e4373550e44d03d9456404cdf4c29b84903dd3
MD5 045a0923fa92fb828381df3ca0a780f8
BLAKE2b-256 a1c62ae884de439d1b9d4b50a7943a713f0a47969598747068436f8769561439

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fb4be06f0ab989a71bcacb00b48cd6368ec14daa4a66122d2585483f2096bfd6
MD5 3a9bea9af653f0b7651590c694b2a0da
BLAKE2b-256 b66092fd6c1b44c7438a076b5ffeef15c5dc18c7e3bc37d8f229dbe0ddba0b35

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4d3640cd2893ec70f1f7ee9c23ddda914b7184f847861dc6c0ed42e40cf47f4e
MD5 b14ee71002bc97af79b1fc6443def1a3
BLAKE2b-256 09efe8add3ee373e859db278465c09de959b308c44b4656386eb4028a8fd33fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d7d1302e96b376ec63b6456d15fa31f110040e3d0e2a9be917e1f63d9b7cff27
MD5 4120d58d3cde1e132f626abd89c4f0f8
BLAKE2b-256 54f42df4c3ca56b530141bbb5ed25bccb01da8bd2c0aafd4ffeb25480291ea2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e56e90f72b30930a9dd0ea4a7c3871f302b5488721c86421d491b370f0b24644
MD5 b5da19dd7988ea358234761656f6c20e
BLAKE2b-256 26ef61450a828f84298be92ddd9dbf6f483125d42bb7f8e8b4b12905ef853655

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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.dev8-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev8-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6e9c7bc50711c58c4184d42d22e95cc1a825c7bb0e3475e82e355f5288430180
MD5 4161fd88ad7d161633b02942096ea674
BLAKE2b-256 3266f61c6ed0a5c70fff0911f3de4cc49fd7c3aea78c4b5ba4c110d5475790f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev8-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 Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page