{"record":{"id":"87ce302777bbe7c9","repo":"XX-net/XX-Net","slug":"import-mac-tray-except-r-please-try-run-sudo-pi","errorCode":null,"errorMessage":"import mac_tray except:%r, Please try run 'sudo pip3 install -U PyObjC Pillow' by yourself.","messagePattern":"import mac_tray except:%r, Please try run 'sudo pip3 install -U PyObjC Pillow' by yourself\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/launcher/sys_platform.py","lineNumber":121,"sourceCode":"    def on_quit():\n        from win_tray import sys_tray\n        sys_tray.on_quit()\n\nelif sys.platform == \"darwin\":\n    has_desktop = True\n    platform = \"mac\"\n    platform_lib = os.path.abspath(os.path.join(default_path, 'lib', 'darwin'))\n    sys.path.append(platform_lib)\n\n    extra_lib = \"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjc\"\n    sys.path.append(extra_lib)\n\n    def show_systray():\n        global sys_tray\n        try:\n            import mac_tray as sys_tray\n        except Exception as e:\n            xlog.warn(\"import mac_tray except:%r, Please try run 'sudo pip3 install -U PyObjC Pillow' by yourself.\", e)\n            from non_tray import sys_tray\n        sys_tray.serve_forever()\n\n    def on_quit():\n        global sys_tray\n        sys_tray.on_quit()\n\nelif sys.platform == \"ios\":\n    xlog.info(\"This is iOS\")\n    has_desktop = False\n    platform = \"ios\"\n    platform_lib = \"\"\n\n    import time\n    import gc\n    gc.set_threshold(200, 12, 12)\n\n    def show_systray():","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/launcher/sys_platform.py#L103-L139","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Run sudo pip3 install -U PyObjC Pillow as the message suggests, with the same interpreter the launcher uses","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)","Reinstall from source if binary wheels are incompatible: pip3 install --force-reinstall PyObjC","If the tray is unimportant, accept the non_tray fallback and control the launcher via web UI"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"try:\n    import mac_tray  # noqa\n    backend = 'mac_tray'\nexcept Exception:\n    backend = 'non_tray'\n    print('run: sudo pip3 install -U PyObjC Pillow')","typeGuard":null,"tryCatchPattern":"try:\n    import mac_tray as sys_tray\nexcept Exception as e:\n    log.warning('mac_tray unavailable (%r); using non_tray', e)\n    from non_tray import sys_tray","preventionTips":["Pin PyObjC/Pillow versions known to work with your macOS/Python","Reinstall native deps after macOS or Python major upgrades","Verify with python3 -c 'import mac_tray' after installation"],"tags":["macos","systray","pyobjc","pillow","import-error"],"backgroundTag":"native-dependency-import-failed","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}