hermes-erkenntnisse/pil-fehler-comfyui.md
2026-07-06 05:38:47 +02:00

1.8 KiB

date tags
2026-07-06
hermes
comfyui
pil
python
bug

PIL-Fehler in ComfyUI

Problem

PIL (Pillow) in der Hermes-Python-Umgebung (~/.hermes/venv/) ist defekt. Bildoperationen schlagen mit ImportError oder AttributeError fehl.

Symptom

>>> from PIL import Image
>>> img = Image.open("test.png")
Traceback (most recent call last):
  ...
ImportError: cannot import name '_imaging' from 'PIL'

Ursache

Das Hermes-Venv enthält eine PIL-Version, die gegen eine andere System-Python-Version kompiliert wurde (macOS System-Python 3.9 vs. Venv-Python 3.11).

Umgehung: sips

# Statt PIL: macOS natives sips für Bildkonvertierung
$ sips -s format png input.jpg --out output.png
$ sips -g pixelWidth -g pixelHeight input.png

RMBG-BEN Crash auf MPS

Der Background-Remover RMBG-BEN crasht auf Apple Silicon (MPS-Backend):

KeyError: 'key'
  File "AILab_RMBG.py", line 247, in process
    params["key"]

Fix

# AILab_RMBG.py, Zeile 247
# VORHER:
value = params["key"]

# NACHHER:
value = params.get("key", default_value)

params["key"] schlägt fehl, wenn der Key nicht existiert. params.get("key", default) fällt auf einen Default-Wert zurück.

Vollständiger Fix

$ cd ~/ComfyUI/custom_nodes/rmbg-ben
$ sed -i '' 's/params\["key"\]/params.get("key", "default")/g' AILab_RMBG.py
$ grep -n 'params.get' AILab_RMBG.py
247:    value = params.get("key", "default")

§§ WICHTIG

  • PIL im Hermes-Venv nicht mit pip install --force-reinstall Pillow fixen — das zerstört andere Abhängigkeiten.
  • Für Bildverarbeitung in Hermes-Skripten immer sips (macOS) oder ImageMagick (convert) verwenden.
  • RMBG-BEN-Fix ist in Zeile 247 — nur diese eine Stelle patchen, kein globales Replace.