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.dev4.tar.gz (78.6 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.dev4-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.dev4-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.dev4-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.dev4-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.dev4-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.dev4-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.dev4-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.dev4-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.dev4-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.dev4-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.dev4-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.dev4-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.dev4.tar.gz.

File metadata

  • Download URL: mecab_python3-1.0.11.dev4.tar.gz
  • Upload date:
  • Size: 78.6 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.dev4.tar.gz
Algorithm Hash digest
SHA256 684793da722b72826c3f34a5dd49b914d376ce80b1496753d81d153122e3cd3e
MD5 b9efb99fe679dde182a7a2f40dfe8e50
BLAKE2b-256 a78cf910ab9f878614f86faf653eb2c619d8f2f676f361584808b20ee50c4d47

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b56bbf4bbec675a34ef7a63c5c6f6bae50312454ca8a866b6143bca623f5be49
MD5 127ddc003f9fdc3186532e79e86e4708
BLAKE2b-256 0be2eea3c1f52426ec3372057dd19b7c4b5ff2b92f55b74e3409853a631491ad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5a00d98f277fb2aef5ff5d8c17ae0ea9fc4a6dc47d5fb3e577f4f89bc94e5949
MD5 da3c223de3b85a0762af33ec724aefa3
BLAKE2b-256 2d6a69c5d9e3e51e601749e507a0f68187e8ce5be2166d6401da63391bf0f3b0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd84e8e90411f01c4e9c53a1aeae919dcc0c1970be4c9d1560ed9024e6221e6d
MD5 c026139cc9470a37fdf78511ce748085
BLAKE2b-256 4945bb8719d0df80e23aa4a7fbff52fed7084dbc30ea16371e3268047ad4abe2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4b18d0a8a404f6e157d30eea4457c9eb983568ad24c498dadc36fa9541b955b1
MD5 8e2552b72ef2dd416961a26c6af75ce9
BLAKE2b-256 766048d705e0ebb39cd046ad4e529e5e4fd21cbbaf7688bad61982ea1fb6dd4d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e5f7d209fab5bca909ae9538261e0c684251103960a56fe3e7b01aff1df9ef9
MD5 d1abaa76408b61e576c305203919a4c2
BLAKE2b-256 db007210e0e0dec686339b08c516e1cc4e5ddf6fb6a8496be789231c72e5333d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 44eee2e65cd8d470ca1d746753c5cc93af917546f6dce6be7a0c4eee48c50fd0
MD5 1d8ba34f8be501560cb661c2b8ab404d
BLAKE2b-256 a4c16e2ba4b907f7cc692af6db42ea817bf120144e3980d3046edb0b498620ac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d27d42b1e6bffb85170e988f07f736b40a2a689a190798710474eed8a7f1eb33
MD5 55fb0a47028f278b87c45de37c3780d8
BLAKE2b-256 e7fd1826303be1a43426f169ee71a6bda87d56207c27393ec44c42d0304a37a6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a44ce694359b6d0736928ae0c1d386bfcf159b15d63a466342a3bcf3b7d5d74c
MD5 43fcfc25447e3a9679fe83ee374fccf9
BLAKE2b-256 b8345c014d67a9d8d660d7deb8111c842c646b2b44c36d5e14cbe77e698041bd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 27664491678b8bd4a15a797de4a7e8901c05ab7837683faf2e8e77f0f07a4f23
MD5 ed6119223f29a8f71e4defd671626065
BLAKE2b-256 36f11ceab953d1a90c3cc8c0c392f70f842932da00b3e47f19c29e911a20e148

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7c7af6940ff337bf319aee6d2f89a2a64eca161383a90b59aebcaad9fb939328
MD5 df2e77432067d7b3d4a156f298f3171b
BLAKE2b-256 a54d2753633bdef78c4c4707d6fd344ca134e7beec539c1e8ac7b388a3f3265a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80693c9c948ce583757f7e70809b274215c867a75663c15449ba323d0c2d41ab
MD5 147205fa2ca6b6122bf3c3e6ef3d0143
BLAKE2b-256 2a3c9a185739ff215aa4d19a616f65671f5dd0a34fcf8f94809fb986ce898ecc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mecab_python3-1.0.11.dev4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0cd34f33ed53d5c853b24e6a4663f72cf1e01e38f2569fd44b3436c6b65b14e5
MD5 fe966df5dd29b74b8e8c192fe5d40678
BLAKE2b-256 f2e899875366be15325a2c1aed97690d276dd8070136d731e30bb1122c54cabe

See more details on using hashes here.

Provenance

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