XX-net/XX-Net · warning

import mac_tray except:%r, Please try run 'sudo pip3 install

Error message

import mac_tray except:%r, Please try run 'sudo pip3 install -U PyObjC Pillow' by yourself.

What it means

show_systray attempts to import the macOS tray backend (mac_tray, which depends on PyObjC and Pillow). On ImportError it logs this warning and falls back to non_tray, a tray-less backend, then continues serving.

Source

Thrown at code/default/launcher/sys_platform.py:121

    def on_quit():
        from win_tray import sys_tray
        sys_tray.on_quit()

elif sys.platform == "darwin":
    has_desktop = True
    platform = "mac"
    platform_lib = os.path.abspath(os.path.join(default_path, 'lib', 'darwin'))
    sys.path.append(platform_lib)

    extra_lib = "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjc"
    sys.path.append(extra_lib)

    def show_systray():
        global sys_tray
        try:
            import mac_tray as sys_tray
        except Exception as e:
            xlog.warn("import mac_tray except:%r, Please try run 'sudo pip3 install -U PyObjC Pillow' by yourself.", e)
            from non_tray import sys_tray
        sys_tray.serve_forever()

    def on_quit():
        global sys_tray
        sys_tray.on_quit()

elif sys.platform == "ios":
    xlog.info("This is iOS")
    has_desktop = False
    platform = "ios"
    platform_lib = ""

    import time
    import gc
    gc.set_threshold(200, 12, 12)

    def show_systray():

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Run sudo pip3 install -U PyObjC Pillow as the message suggests, with the same interpreter the launcher uses
  2. If deps are installed but still failing, run python3 -c 'import mac_tray' to see the underlying traceback and fix that (often a broken Pillow or PyObjC binary)
  3. Reinstall from source if binary wheels are incompatible: pip3 install --force-reinstall PyObjC
  4. If the tray is unimportant, accept the non_tray fallback and control the launcher via web UI
Defensive patterns

Strategy: fallback

Validate before calling

try:
    import mac_tray  # noqa
    backend = 'mac_tray'
except Exception:
    backend = 'non_tray'
    print('run: sudo pip3 install -U PyObjC Pillow')

Try / catch

try:
    import mac_tray as sys_tray
except Exception as e:
    log.warning('mac_tray unavailable (%r); using non_tray', e)
    from non_tray import sys_tray

Prevention

When it happens

Trigger: Running the launcher on macOS without PyObjC/Pillow installed, or with an incompatible PyObjC version for the current Python/macOS release; any exception during import mac_tray triggers it.

Common situations: Fresh macOS setup using system python3 without the native deps; macOS or Python upgrade broke the PyObjC bridge; Pillow binary wheel incompatible with the new architecture (e.g. arm64 vs x86_64).

Related errors


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/87ce302777bbe7c9. Report an issue: GitHub.