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.dev7.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.dev7-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.dev7-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.dev7-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.dev7-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.dev7-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.dev7-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.dev7-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.dev7-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.dev7-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.dev7-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.dev7-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.dev7-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.dev7.tar.gz.

File metadata

  • Download URL: mecab_python3-1.0.11.dev7.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.dev7.tar.gz
Algorithm Hash digest
SHA256 e6528870312c0aa644288c8cfc41a5d6301a58eae683b4a7946c8f36c838b4f8
MD5 57be835df5b93c8dd949d9ccb60cc942
BLAKE2b-256 ffbf1db851d6ef0c903314b5c140131c6f8e08f32b30946616000b8ae2198fc8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c1cb88c97acf07ad592efdcec332b2a34d7f49a50b4675ecd5f40bdf9502ab0f
MD5 9eaf00040f444159ab7d2700c76b1be2
BLAKE2b-256 949b9e40ffa78f902762cba5939c918c99cf6968a92ea6a9c1c4eb87a5b5f43b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9212b6ddf63598e3bb51c797cd5100007cbb9607f3dfd3abce9f950dc5da752b
MD5 5f06fa5bfd5b81c69b830fc29f1a908c
BLAKE2b-256 9767b9f73f9fe26dbc023fd1851332514103bca71ae2a4041b59988f5db7dfc8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ccd8e8dab7e7386062fa84070d55f8ca92af03711a9ee84dcba2d57d42c1499f
MD5 3a3c171167cd267c3cd8959f37dda63e
BLAKE2b-256 ff6f7180cca72df37e5af851ffe98cb16f4e60c0e818b464acc39c36d801c9d5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fffb5876fa8b810e93663f66793b509b5b27a1757108950ab8e30638b5d725f6
MD5 371d6664fe95f601e3848f87297234e2
BLAKE2b-256 53ef506ad2f1e01a9e2abc2ed951522b0ba7a409551fc7dafc7d717776227519

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b657a25b433fb748bd782d58812bfe8643568617fee533e8a2ddc206bd3a2d1b
MD5 ee3f279867de54bca5bb47ea692b6f01
BLAKE2b-256 0f3761f5c680792cb16a48e12396e34b381e022a99f7085165c9664653767953

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 51b819f92d1792e96eb6525200d281ae67caed9c1399a449e38ab3f6001ddea7
MD5 5e91c0347a61c88435a2e68c01758ccd
BLAKE2b-256 5441552b39fee4af8526d5634e9726afe2c37b40a9621a1afa93d4639f20f2be

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8026d87caf3b9ab1456b6c62232c530df20adbf89efb479b9e914e7403bdc131
MD5 c78c235992df6ae7a84291bc32b93ee2
BLAKE2b-256 6d47177e417f2223c1cf4ee479f7d79956516e82682204d19ac157793eae040a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ac946f2d314956be9c97b864dd6fb99b3ec71760116dc19af3b4e98a91bf9abf
MD5 e37b159940641210f9546fa2fd1bfc28
BLAKE2b-256 d340fd06a287b4951f05e55523a048d222a4e7ea782a110abedca402161e6e6f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 43fb5b2fd3710a03749e2b19cf325213e1ef6ef9b9e8fa2528ac4b30c61cf4c7
MD5 2194a3ad9da7d7a4c3acb9b6c3999b76
BLAKE2b-256 d729301c6fad2f97afa32fe744e6efd564ff484a04d1f05da45a1a621960d7fa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6b5a44c62458b05ee76896281b9ceb9e2a7ef2170300e2690b3b3d4b1911e38f
MD5 f03f85a0533b0756018761166ab41c57
BLAKE2b-256 1966c88eac3065847bfd8005221a1d697dbcdb45201be4d1c43dceb67753e87c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 73951a43a1798a2a80d16ffd5f13973fa30927a6887c682abc80516c48d57eee
MD5 e2bcbcc10d944d38bbc3db3a4c51a746
BLAKE2b-256 247f8f0232e3899259ab96d9fb85c87452c706b90a24e31619f51debc599bd7b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 62bf3e01c3533a910bd118ef75df9fbc1d1800b63b85552aedbd62c70229b377
MD5 8cedf1d7b4b1afc489ed43c4b0383753
BLAKE2b-256 5abcb7ef9335953d2803f7bf269298bae19ed45491e89af90fac32d1091e3824

See more details on using hashes here.

Provenance

The following attestation bundles were made for mecab_python3-1.0.11.dev7-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