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.4a2.tar.gz (77.9 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.4a2-cp39-cp39-win_amd64.whl (510.4 kB view details)

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.9macOS 10.14+ x86-64

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.8macOS 10.14+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7mmanylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.7mmacOS 10.14+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6mmanylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.6mmanylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

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

File metadata

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

File hashes

Hashes for mecab-python3-1.0.4a2.tar.gz
Algorithm Hash digest
SHA256 21406c700dbca5bfaa089959206d088568e1d423ea52d2df8cf7b7b7090abb87
MD5 aa6f839daf738fda29287640cedd7654
BLAKE2b-256 f423ed27cec45ef51e0e4d4e61cb20a5955a17eff415e4ea5b5f9d853722d875

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mecab_python3-1.0.4a2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 94bd1205004b88dd48c5036c4087ce983fbd67c8bb7844f1596bad6224f6fbf8
MD5 689394739b639cc700109d983e9228bb
BLAKE2b-256 38e60a00da1031671d349ad28980dafbe92bc295b00ca34bfdcb335a366a1a13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4a2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f2dbfecea3e74dc316d923bdc3fcad5b1276710a450a67d035b3518713799628
MD5 8fd319f5aab1cf6f69486eed75c7b647
BLAKE2b-256 0a6dfa226eecb34e9be050443782391f6cc34b3549a779d745cb4d1b72fe8676

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4a2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6d9651a63509f0d135f0eda84aa5d99b3ec81fa776909214db1b7cb1de4758bc
MD5 32fb153db5be02882cd0d94a467696b4
BLAKE2b-256 4553583f114d588602baf320de82689d1529695f67e66dd7eb2a902f9fae392b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mecab_python3-1.0.4a2-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 072a2b43f4035fe0efdf9cef407626d188c7d8c0aba41b0cbf8b010a413336a1
MD5 c1b44309ff917d8185e19c18e790ad1f
BLAKE2b-256 2c9e673c553dbff782b05c449f8fbe4a8621f43cac4d3639e9f8378c4bc207a3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mecab_python3-1.0.4a2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 074d48b93fd2f82bce09d8d87b96a45b4f056466f1b169fdbd9116315ddebab8
MD5 3867c33ef2c9447019839a60a30d32a0
BLAKE2b-256 96e10d8477974d5548ed9baccff533037beb773cb7136474380ff9ecf748251c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4a2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 03179fe1210fa2abe79d8aa499f547923950c99a9faadc880baae8060908e03c
MD5 452acfd14cfb5ab9aca42d18f08ed22c
BLAKE2b-256 fa1073c1ee569ba6aa94b4665f7a8f8de643d633df309d04dc830db4cad7db70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4a2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1de6442d6ef12d52ca4bb4d948198a96101f5a188cd90ed5aeb1f63baf4be597
MD5 9c13be5408dc5e91ed89accafa279a4a
BLAKE2b-256 42f533d785ec5bd9ce53699d23c34c94aed25ce66812fde0e3e1d8f39a32d018

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mecab_python3-1.0.4a2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 7085aa3132e5978d40a4f47b5b0b9bfff45d85f477c3c51be7da79c47780a3f7
MD5 39a324ba4794fe1c992c6fdade875a63
BLAKE2b-256 be11180ef3ead7c3308e5a4fadc75667ab8ec4e548b3ffc9df4e7c6f6358aaee

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mecab_python3-1.0.4a2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 3fa513af42563d3228b67d034cab3be0e71f667d4371a30ed5d69c33fc5ba8f6
MD5 4e1830c3e0520b27a6eba7f57d64739d
BLAKE2b-256 5cec09a7890d66004203c1a3227e9c90ca969b2f0ba481e3c2fe885e79fb79f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4a2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8f4cb1774a455209d410d8a9218afa96eaf53442c932df6a240209ddecb67be1
MD5 42c3ba98f063166e9681e601e790a189
BLAKE2b-256 2ea9b288acb6538bfd700fc249243dfac4c9458e75b1eae95077a4c7a67c19d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4a2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 21859e8cb551de803473539a493ecec244a9753d458db82d43da3dcc27d7fa87
MD5 f3d9e8e22d19cfa0443ecd17a39b67e3
BLAKE2b-256 30beaaccc981bea062fddf1398d19318773b8b5b6728d29f03a37c24cbfe8816

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mecab_python3-1.0.4a2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 cea30696ec59f0598650f2fa7e28f674e3f6fcfb21d4e27906bc6154240e5b98
MD5 e6e3041fc89b33354d5cbc0a4da90355
BLAKE2b-256 c3a0828034ff4c9f7380d30688f0b6e9ca7e489e23b0515e0338266428d40734

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mecab_python3-1.0.4a2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 510.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8

File hashes

Hashes for mecab_python3-1.0.4a2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f8cdc6d99968fd5e105fa049ca43c7fa37a433f0a8fbfb8344a1131cb847da9b
MD5 291a43f87cc43ea50ff608e675e8e128
BLAKE2b-256 9b1422ebdcd5f4cba3fbc6f65ab4d3bf8f82d7ff54547cba030cf26af58ee974

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4a2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0571af88e50214432ad559bdce1156c8386812533ab355aa5640148c9fb1897b
MD5 ef601d94af3c66e6810087f9775b89f3
BLAKE2b-256 31c365b3a009ffaff1bb59364b2094dc3be30b6e31faf8599fb3b5c7c3e2cc8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.4a2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 dfad5c989f4cf5e9ed25a623502d50b57a98a3b62520ef1f24ce1919f7406afa
MD5 80329c2b4016f606378834f8daab9096
BLAKE2b-256 d38ed9c44697e0c4df31ec59c521b23f4e82418152cc59b5ec321368daac0ef1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mecab_python3-1.0.4a2-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 6f0e39482cf3594f0865173b9f242203425b35ae768ab10c76935c25261433e4
MD5 88b566abce6f39ba3178ca5dfac8e1dd
BLAKE2b-256 603355a0c574be71a55355b5d057faac5ce55c579611778fc725ef306fd4ec32

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