mozc-ffi for Python
English | 日本語
Python bindings for Mozc, Google's open-source Japanese kana-kanji converter.
Mozc runs inside your process, with its dictionary built in: no mozc_server, no IPC, no install. Unofficial and
not affiliated with Google.
Install
pip install mozc-ffi
It needs Python 3.10 or later. Each wheel has the library inside, so there is nothing else to install.
Platforms
Linux x64 and arm64 (glibc 2.28 or later) and Windows x64. There are no wheels for other platforms, such as macOS or Alpine Linux (musl).
Example
from mozc_ffi import Mozc
with Mozc("/path/to/profile") as mozc:
segments = mozc.convert("きょうはさむいですね")
print("".join(s.candidates[0] for s in segments)) # 今日は寒いですね
# Lengths fix the segments: ここで / はきものを / ぬぐ
segments = mozc.convert("ここではきものをぬぐ", [3, 5, 2])
print(segments[1].candidates[:2]) # ['は着物を', '履物を']
# What the user sent ranks first next time.
mozc.learn("ここではきものをぬぐ", [3, 5, 2], ["ここで", "履物を", "脱ぐ"])
print("".join(s.candidates[0] for s in mozc.convert("ここではきものをぬぐ"))) # ここで履物を脱ぐ
print(mozc.predict("ありがと")[:2]) # ['ありがとうございます', 'ありがとう']
The outputs are from a new profile. Once Mozc has learned from you, its first candidates follow your picks.
Calls
Every call is self-contained. You pass the reading in hiragana and, optionally, the segment lengths and the text just before it, and get back segments with candidates. There is no state to keep in sync with Mozc.
Mozc(profile_dir=None, *, incognito=False, library=None) |
Opens Mozc. Use it in a with block, or call close(). |
convert(reading, lengths=None, context="") |
A list of Segment(reading, candidates, descriptions), candidates best first. lengths fixes the segments; without it Mozc chooses them. context is the text before the reading, which helps the first segment. |
predict(reading, context="") |
Completions of the reading typed so far, best first. |
learn(reading, lengths, texts, context="") |
Learns that texts[i] was picked for segment i, so the picks rank first next time. |
clear_learning() |
Forgets everything learned. |
flush() |
Writes what was learned to the profile now. Closing does it too. |
close() |
Saves what was learned and frees the engine. |
last_error |
Why the last call failed, or "". |
mozc_version |
Mozc's version, such as "3.35.6354.102". |
Segment lengths count Unicode characters, not bytes, and add up to the reading's length. descriptions has Mozc's
note on each candidate in Japanese, such as カタカナ, or "".
Errors
A call that can't do what was asked returns [] or False, and last_error says why, in English, such as "the
segment lengths do not add up to the reading's length". It never quotes what was typed. learn returns False,
and learns nothing, if a text isn't a candidate of its segment.
Mozc(...) raises MozcError when the library can't be loaded, speaks another version of the C API, or Mozc
can't start.
Profiles
The profile directory holds what Mozc learns and is created if missing. Mozc() with no directory uses Mozc's
default (on Linux ~/.mozc if it exists, otherwise $XDG_CONFIG_HOME/mozc or ~/.config/mozc). Mozc keeps the
profile directory per process, so open one profile per process; closing it and opening it again is fine.
Mozc(path, incognito=True) learns nothing and leaves the profile untouched.
Threads
One Mozc can be shared between threads: calls on it take turns. A call runs on the calling thread and takes
about a millisecond for a short sentence.
Finding the library
Mozc loads the library the first time it opens, from the first of:
- the
library=argument, - the
MOZC_FFI_LIBRARYenvironment variable, - next to the
mozc_ffimodule, where the wheel puts it, - the system's library path.
It stays loaded until the process exits.
API reference
Every class and method, from the docstrings, is in the API reference. Editors show the same docstrings, and the package is typed.
More
BSD-3-Clause. The library contains Mozc and its dictionary, whose licences are in THIRD_PARTY_NOTICES.md.
Metadata
Release files for mozc-ffi 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mozc_ffi-0.3.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for mozc_ffi-0.3.0-py3-none-win_amd64.whl |
| mozc_ffi-0.3.0-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for mozc_ffi-0.3.0-py3-none-manylinux_2_28_x86_64.whl |
| mozc_ffi-0.3.0-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details for mozc_ffi-0.3.0-py3-none-manylinux_2_28_aarch64.whl |
Total release size: 45.4 MB
Release files / mozc_ffi-0.3.0-py3-none-win_amd64.whl
| Download URL | mozc_ffi-0.3.0-py3-none-win_amd64.whl |
|---|---|
| Size | 14.8 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a0981e39e0a2dbd366c8d450d6ba51e8255088af352c4f6b3f82f27dd3ba14af
|
|
BLAKE2b-256 checksum How to use checksums |
01892bdef2fd54f37ad7faf8d82fd996eb606753110870b6bee3c25d928749d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logRelease files / mozc_ffi-0.3.0-py3-none-manylinux_2_28_x86_64.whl
| Download URL | mozc_ffi-0.3.0-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 15.4 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
9c07c543829e2881b31a036c96ec9e950e100371b9f6db5290769ba89bf24422
|
|
BLAKE2b-256 checksum How to use checksums |
eb04c00630fa9fb9fff415cd79c48b66e196218954ae0cc8970146a4d7d792a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logRelease files / mozc_ffi-0.3.0-py3-none-manylinux_2_28_aarch64.whl
| Download URL | mozc_ffi-0.3.0-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 15.3 MB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
f5520c08804d262fd6a7279b018ccd0df16815a23fc9ca2af1c435c37411c142
|
|
BLAKE2b-256 checksum How to use checksums |
9aefe185f79828f45bd64db37ca4944f56c210b6c329eda45bbb1d91d075ca04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logSecurity for mozc-ffi 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 3 files in this release have been uploaded with provenance metadata.
Attestation for mozc_ffi-0.3.0-py3-none-win_amd64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.