--- date: 2026-07-06 tags: [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 ```python >>> 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 ```bash # 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 ```python # 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 ```bash $ 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.