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 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.7.tar.gz (78.1 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.7-cp311-cp311-win_amd64.whl (501.4 kB view details)

Uploaded CPython 3.11Windows x86-64

mecab_python3-1.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (588.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (567.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.7-cp311-cp311-macosx_10_9_universal2.whl (314.5 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

mecab_python3-1.0.7-cp310-cp310-win_amd64.whl (501.4 kB view details)

Uploaded CPython 3.10Windows x86-64

mecab_python3-1.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (581.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (560.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.7-cp310-cp310-macosx_11_0_x86_64.whl (274.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

mecab_python3-1.0.7-cp39-cp39-win_amd64.whl (501.4 kB view details)

Uploaded CPython 3.9Windows x86-64

mecab_python3-1.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (581.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (559.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.7-cp39-cp39-macosx_11_0_x86_64.whl (274.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

mecab_python3-1.0.7-cp38-cp38-win_amd64.whl (501.6 kB view details)

Uploaded CPython 3.8Windows x86-64

mecab_python3-1.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (577.8 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

mecab_python3-1.0.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (555.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

mecab_python3-1.0.7-cp38-cp38-macosx_11_0_x86_64.whl (274.5 kB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

mecab_python3-1.0.7-cp37-cp37m-win_amd64.whl (501.5 kB view details)

Uploaded CPython 3.7mWindows x86-64

mecab_python3-1.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (575.2 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

mecab_python3-1.0.7-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (551.8 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ ARM64

mecab_python3-1.0.7-cp37-cp37m-macosx_11_0_x86_64.whl (274.3 kB view details)

Uploaded CPython 3.7mmacOS 11.0+ x86-64

mecab_python3-1.0.7-cp36-cp36m-win_amd64.whl (511.6 kB view details)

Uploaded CPython 3.6mWindows x86-64

mecab_python3-1.0.7-cp36-cp36m-macosx_10_14_x86_64.whl (274.1 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file mecab-python3-1.0.7.tar.gz.

File metadata

  • Download URL: mecab-python3-1.0.7.tar.gz
  • Upload date:
  • Size: 78.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for mecab-python3-1.0.7.tar.gz
Algorithm Hash digest
SHA256 d9933bf4fd944260f58b421f8639bbc1120413d1f3fcde8c55097221dc13d51d
MD5 a5267ec8fa5a3e3eaec65b0a78aab3b6
BLAKE2b-256 0bcb9bfc3aa31eae7fbf078ffeec9e44ca11982f0407028839c53fd3f481bb17

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1c365678f4b9dbddf82571042fd0c825f87ff06b575f2ae336092510a1676adf
MD5 e338b8c80f95587cf97a301d435d3519
BLAKE2b-256 1a1618526cdc79bdaefd2f0fe14abae8215b52d87c1b2cd51b9bd44159a241a6

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b3d5d2bb375c40a10f8b13b80d2c3b2f02acda3392cf5157c53b3132ef1ac053
MD5 4e76794333d6f579648317d9d1637d97
BLAKE2b-256 70f45f126d0b2bc3536cd23d21f9abd1b9046683d7a2f0ce014a044c173ef76d

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e515440e33eedec3ba0f461a21d52d8ecb7a8f0fe2fb130ae67efa8aab8a01c0
MD5 21259202d1eaefa6a7208a274c862b7f
BLAKE2b-256 eb1b447768de24ad76478e754b912be2ee7ef6ab7ce1f41da0e8b48a0b27d2b6

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 b7ad53cd8c063c171ef7fd09e6e3fddf6fe30c57625ae223ae6e058eb33add2e
MD5 964cff4b7dbcc47e1a258d90d722e230
BLAKE2b-256 fc9b725a9a80c453ad9441cc4bc0b65b0c58fe7aca55ede9645571101d4743c1

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3486e3f08e534feb7f56063522fd55ee7caacf9ee42d5bce9a9e1926df5999b4
MD5 0f2035cf9b416b9c1a37514c2321d71f
BLAKE2b-256 d3348dbcbbc3b9d46fd6f7b2ea34ddaa5ebf80a4610148c16417aadbc0e547fe

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b468d08d519d46af98d545c36031a93f4f22187bd4fb45ef8b44d907497cae52
MD5 9dcacf8833c34d776327bd1a09afd6aa
BLAKE2b-256 7f5c2ce330f543abf7f5ad439ecdcccc228c4c3f8de91dc69ce38e8e64fd70dd

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 992db8baaa05c50233ff9d1166b7df052a8f0d559f69394fda629293552ddfa4
MD5 f53c422eb241f31139efc6f7a1ca3c63
BLAKE2b-256 b99736585de402a51602f352a7db5b2c6e21ae164868d4321b45bb1ec4666089

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 c3d12983f07e0051d2ff0e3edb870fcb764d473e014561ced8d6d89034635d94
MD5 511c306bb6013757addce511f559e91d
BLAKE2b-256 7926ebbb934b71eb3b7cc3b8513fa304a9bd7c834dde8c9ae124a1b67155fee1

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 97ecdf2fe7084e0da994bc8d196efb934ba0d3719a5fbc93f5971858b3a602a5
MD5 e40986c30e5b82f070a9a9ff4c2111b3
BLAKE2b-256 2ca5eb6c5883977822e39c1be491845570b67e46d6a0e00aae8f8e4e32c97125

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7977872cd52ca8256b7e10fff8198d3a9c325e1d62ee98f3481cee40340f3ebf
MD5 0305026c32cbb8a80238638f78e7b303
BLAKE2b-256 e005dabf4bd726ae2b9e91a403d6a059ea14aebb785c29322c61f3387f71f018

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 218b6194db4a785a1a7bacd9c3df09712ffaaa442f7442482dd64fbb6078a8c0
MD5 ecdb8088b67bcb13050f64618aef6ece
BLAKE2b-256 493a9999893b030273cfb176124383ea9799fd1053b40abb989d4c91d72cb74d

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 017836d98e1cbd881e64e028947f0f7f89804a8b3cbb4f1d2a6a73925c834c71
MD5 898012f05bc96c43af0219ae0241b423
BLAKE2b-256 30041831d01dfdaf3d7ed6cfaa7db308af2e05a34f80f761e5fc380740b5e6af

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ad17e6fc0ecd6d2912a64bcbc3c0972749b7ed0a7d71ba98d82d7226554d7d94
MD5 475b983cc11f50e943e3d87f40353852
BLAKE2b-256 fdaf8fc5dc8132a2c1011c867ceb874680b5764cfa5a6e539c984c0b2dd34194

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e56748b11fb8d831680880a061374d423859ba8d4ea1757d9bd1429be268da1
MD5 c5b5ee1f1b9fc354f4f4055154455de2
BLAKE2b-256 368d75f2c673e8ad6e626219cc205a30a7d6f5a685d8d95753dd5f1126596424

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f180fc227ecff1274529a0650c182266ea422c05f7616075cd6b491377065aef
MD5 5d7230f7607b8cd68e4265d1704f973c
BLAKE2b-256 431b59bd8ec7146f67f01884b4fb815b57972c9af477442e767e739855c8293b

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 e92bd03328f4f9520360bd50d82885884752558eedeb23da460bd1905b5d9332
MD5 42e14719fa545b905a0ec428421dddd2
BLAKE2b-256 9cb3c57b804038ebcdf7c2d957edc1c5fe6733228daf0f2d90da2899b0b7aa5c

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 7fbc0e0a8d52f3ea62933b4e39dbda87b84306977e3e4a2d5e08ee978d535d72
MD5 02d01d7a8503bb89d827bc2fae2671ee
BLAKE2b-256 1d94d098c87189a15db1a263521e5b873c1975828be32bedd55c866ad3e82dea

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92e63b2cdd81a342e260d10a18d16fe025c289682208d26a656517cdd1dd0f25
MD5 8057ac2199e71122df1fd2259e899ba0
BLAKE2b-256 b45f8a155c0162e11452c87fea3c5aa11dea13070e9056681c1c7aec36548ddb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 79733196b1fb769bbc43449f8a87f57cab3be92f0ce37549ddd6c3cc2aef92e2
MD5 afa93dd6a33c59efb78222a68f90dbd9
BLAKE2b-256 cc6194c526980b83e657dfbc451ed61045f5e8dffe143fd9898b177bd19c6a01

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp37-cp37m-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.7-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 9ebd7050b4584a9db9d822befbb02a92225650c2a533b606f6712171be4da344
MD5 903bfb57afaa5dce579f82a410eb7941
BLAKE2b-256 dbbed5dcb269b731d088b7e0d29539771156a2bea9bec7c10bf2697d5c300aa9

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.7-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 511.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for mecab_python3-1.0.7-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 74e923a763260a0337b9c316cc9ba58428b8cf9810c703e1418a020ace63a2b1
MD5 7de01d86bbdbf2a918aaa173496716d9
BLAKE2b-256 09d51aa7475a36fb1cfffa9827b4af4d982d8acc862def5e9c4d35e7737d8d8d

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.7-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.7-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 274.1 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for mecab_python3-1.0.7-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2eb5427474956b9212bbc9a761188f89acdcc60ee903d80f8767a6a810083ab6
MD5 8b35c90e7bd6018dc7274439462979f7
BLAKE2b-256 2975e1eedb97cdc8360c2bc378f95ea117d3586cc7a9d93cfae378b88c9ebd2a

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