fxsjy/jieba · warning · NotImplementedError

jieba: parallel mode only supports posix system

Error message

jieba: parallel mode only supports posix system

What it means

jieba's parallel mode spawns a multiprocessing Pool of worker processes, which is only implemented for POSIX systems. On Windows (os.name == 'nt') enable_parallel raises NotImplementedError instead of silently degrading.

Source

Thrown at jieba/__init__.py:601

    else:
        result = pool.map(_lcut_for_search_no_hmm, parts)
    for r in result:
        for w in r:
            yield w


def enable_parallel(processnum=None):
    """
    Change the module's `cut` and `cut_for_search` functions to the
    parallel version.

    Note that this only works using dt, custom Tokenizer
    instances are not supported.
    """
    global pool, dt, cut, cut_for_search
    from multiprocessing import cpu_count
    if os.name == 'nt':
        raise NotImplementedError(
            "jieba: parallel mode only supports posix system")
    else:
        from multiprocessing import Pool
    dt.check_initialized()
    if processnum is None:
        processnum = cpu_count()
    pool = Pool(processnum)
    cut = _pcut
    cut_for_search = _pcut_for_search


def disable_parallel():
    global pool, dt, cut, cut_for_search
    if pool:
        pool.close()
        pool = None
    cut = dt.cut
    cut_for_search = dt.cut_for_search

View on GitHub (pinned to 67fa2e36e7)

Solutions

  1. Guard the call: only invoke enable_parallel when os.name != 'nt'
  2. Keep sequential mode on Windows — it is correct, just slower
  3. For cross-platform code, gate behind a platform check or sys.platform.startswith('linux')

Example fix

# before
import jieba
jieba.enable_parallel(4)  # crashes on Windows

# after
import os, jieba
if os.name != 'nt':
    jieba.enable_parallel(4)
Defensive patterns

Strategy: validation

Validate before calling

import os
if os.name != 'nt':
    jieba.enable_parallel(4)
# else: stay sequential

Try / catch

try:
    jieba.enable_parallel(4)
except NotImplementedError:
    pass  # sequential fallback on Windows

Prevention

When it happens

Trigger: Calling jieba.enable_parallel(n) on Windows (os.name == 'nt'). Any call, with or without an explicit process count, triggers it.

Common situations: Code developed on Linux/macOS and deployed to Windows; CI running on windows-latest; tutorials recommending enable_parallel being followed verbatim on Windows.

Related errors


AI-assisted analysis of fxsjy/jieba@67fa2e36e7 (2026-08-27). Data as JSON: /api/errors/3a87f4aa00b96344. Report an issue: GitHub.