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

Uploaded CPython 3.11Windows x86-64

mecab_python3-1.0.6a1-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.6a1-cp310-cp310-win_amd64.whl (501.4 kB view details)

Uploaded CPython 3.10Windows x86-64

mecab_python3-1.0.6a1-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.6a1-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.6a1-cp310-cp310-macosx_10_15_x86_64.whl (274.3 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

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

Uploaded CPython 3.9Windows x86-64

mecab_python3-1.0.6a1-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.6a1-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.6a1-cp39-cp39-macosx_10_15_x86_64.whl (274.3 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

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

Uploaded CPython 3.8Windows x86-64

mecab_python3-1.0.6a1-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.6a1-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.6a1-cp38-cp38-macosx_10_15_x86_64.whl (274.5 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

mecab_python3-1.0.6a1-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.6a1-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.6a1-cp37-cp37m-macosx_10_15_x86_64.whl (274.3 kB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

mecab_python3-1.0.6a1-cp36-cp36m-win_amd64.whl (511.5 kB view details)

Uploaded CPython 3.6mWindows x86-64

mecab_python3-1.0.6a1-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.6a1.tar.gz.

File metadata

  • Download URL: mecab-python3-1.0.6a1.tar.gz
  • Upload date:
  • Size: 77.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for mecab-python3-1.0.6a1.tar.gz
Algorithm Hash digest
SHA256 70d783988af5f503a1488ae916200f3ecb7188c9402e87f2aba8236ed18555b4
MD5 9586d2648e8e748da6a255a0f6fcd79a
BLAKE2b-256 5b43db2a58dfec793cc1cef8d6041cc2a841aeccf455ac4a4a93fc5def44f9f6

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8dbc8f9bcd212d21605d15e3d9f1e2336107a835e816dcdad134972260643558
MD5 1919c0ece84f1eed9f5b18d9d491dc49
BLAKE2b-256 95ef2cca68e38dd6c9a784f748a7b72eb8233df7c4cad3112065c7891f0fe8c2

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 50a3a17d5f5217a925734a6649629a9aa3cd87d776e329115a051ac5c390b093
MD5 1ec94072ea5110b8cb36463c267e7fee
BLAKE2b-256 926740c5a517fa34d80ed0d57c6bc4f26f3d35ff33d65bb92ca0de9dfab96696

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 eeab4eef4c14b4c2be3e06b798284a417c96ede4d3427d592665f49c7174ca83
MD5 049fe782c345ae2707ead96f1b1ec096
BLAKE2b-256 c2591df541378e656da6e02fb2f1cc6993504db0685c941d69f69a6ee355f31f

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9a50a5167c9abc5c4459ad5cb0e8ef402e7a9d499ab392b0e25e22b5c20bc16
MD5 84c0a360dc91f9cc1fe03af2e6cedee2
BLAKE2b-256 03a336a8ee13530569bbb63efcc0cf59a56aa51533dee80474168eafd0373cc2

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7b3e01237f50a8387e67ffee27e7a44505db84b93eb04600e7afc436b7c5799d
MD5 9a0322ffc17947e7f4d7727e0013a971
BLAKE2b-256 aded4d141364fce8fd193366264402e0334dda99bcb74e06850b38dd809f8654

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 715cf2a1e8f736f9608b6598d210006801e316b287b0eaee0d292b80bdea052b
MD5 aa9a83e3d1797631cf618a192b06913d
BLAKE2b-256 fb4c700362930106b486269e34ece7ca3d48a931b3d69be68f9dbb2dc6cf9852

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1c2118a4971ef111828f9a9a5440c30ff073ab1e2ba5d5bf0dcbc5679019881f
MD5 ebe5822b34dcec23fbc325fc9ca7083b
BLAKE2b-256 a86ad08b42851064eb4f6ae751449036600552cd10c1152ec72e9ea7699bb955

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f7677286db2fcc66392e0ad03f93f38f1092112118c32133fda12c5bad066fbc
MD5 21c214c846728779bde685c878752be5
BLAKE2b-256 986ddedb7f0f375549949186f4f63e418a94947ca756c144f1fc38521273e114

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5b847adf76a955be47db48363ad317c0ee5fa0813d2eef072b44bf4d71e2cef0
MD5 435d9231fbab0e1e1116ca260287db85
BLAKE2b-256 68d8209ace31a5714b17d9dac98946311b55631d50942b4ff7634fb15c9a4809

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d414dfdaef281441ace19958834d2d3c609c85cbe158a31458109936c4bcba68
MD5 a997bbb5fe043138c010311bff505a3b
BLAKE2b-256 4a9bde932b16749664d12ed00cbe09a34f06fecc3cbaa90c6606fec1b52915bc

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 fe218d5a6df09ad0ccfd3e39d7a2201fb3a7ce3ab856603e81f77a73b3d5ed76
MD5 17bb87715e30639e4eb3423f3d7b2387
BLAKE2b-256 cf6bc568dce7b927e53b88ca12b0ad951e2a5774d2e6cba987cab576f2dfde17

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f162094bfc63b081f52822c1b948dce2b49bcec9a78ebfd522f7989db771986f
MD5 bf5b4b0fc87c9f7b8da8d979e157cf1d
BLAKE2b-256 e2453ebc9f391e3ab32c54556d5f5310d802e5315482defa2305575fc8d4573c

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1cefbda6c4c685d20cd7d32b38904bda4656b73e80a0de1eafcc4e90288518f3
MD5 9398e51c4983e48e74fb972b832ab240
BLAKE2b-256 6d2c63a8c7a26cc8a57c90b6e02ab73368ff3eaeeb5c135d9c98da47b6f994bf

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 111fa302f4bb027caa8cb9124686936a23b5e505aeb0f3430673602cae9773f6
MD5 f16c8fe923ce903dbe89cea5f8bf3972
BLAKE2b-256 8bd580116b1bb40b732ca216f9d08723afbadaa79eeb4d7aefddfecc182f8f83

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c6a343c2600241d70755bb966b0e23c401912bbf2e85de7af69d595c6acdef84
MD5 2e7a847f414209bc5087c0bc949de19e
BLAKE2b-256 52d0704cc377a69986793652c8b8647dd03e2b29cc1204409fa911c3902f50f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 adb856a9daf33f85e7fd2379557ccc5913452ea3e320173101248be8b96c88b5
MD5 4591d667fe3ee6775483cc0c99136836
BLAKE2b-256 3561dbcf1b8868b41e70f4f7cc195e17fcd6f7711d0cea56f1497398c0e8ade0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 75bde68bf46acc3abc6cc1df38c227650ce68b30cc53f5f6ea1d146066684b46
MD5 4bed7d76c65e4d014885a23a65f636a1
BLAKE2b-256 5e765190e90e5f304d7cbe4ef9441c515b226bb304d77dff97a061b988e3d963

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mecab_python3-1.0.6a1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3e5a163a7a25fb0c45f94f77bb8498500a8f13ea64759968e68887f34d7869d2
MD5 a2f17e930a61f47ae7c5584e354f2efe
BLAKE2b-256 fa8fbd86fcebc655a6e9a21b42f0ea9638d2a604c2a157b47b12b36a021d5819

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: mecab_python3-1.0.6a1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 511.5 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.13 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.6a1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 8ac8eb048e8b819f17f9746356436d009384ff2b9c6f086c785095ce253221e7
MD5 0ac846a419b359dbb3665600e3fa6610
BLAKE2b-256 e3fde0d67e10ff11fdfb45015b85b5770f772dae7013747951b8045f5342b00d

See more details on using hashes here.

File details

Details for the file mecab_python3-1.0.6a1-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: mecab_python3-1.0.6a1-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.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.13 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.6a1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a6cf27bf200100dd8e0636fd8008572487788b085ee0dfafbf42e3c4212ef6c2
MD5 962ed10cf19447ff1657f793eccd848f
BLAKE2b-256 95271916665bbfa4d818da2e097ce8414c23630786a69b8f08dfbe4061e028ed

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