ModuleNotFoundError: No module named 'PIL' in ComfyUI
Fix ComfyUI No module named PIL errors by installing Pillow in the exact Python environment that starts ComfyUI.
If ComfyUI logs ModuleNotFoundError: No module named 'PIL', install Pillow. The import name is PIL, but the pip package name is Pillow.
This is the same kind of package-name mismatch as yaml versus PyYAML: the module users see in the traceback is not the name they should install.
In the SEO Lab portable repair chain, missing PIL appeared after PyYAML was installed. Installing Pillow moved the startup log forward to the next missing package.
Fast answer
For the GitHub Windows portable package:
.\python_embeded\python.exe -s -m pip show Pillow
.\python_embeded\python.exe -s -m pip install Pillow
.\python_embeded\python.exe -s -c "from PIL import Image; print('import ok')"
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-buildDo not run pip install PIL.
What The Log Looks Like
Typical traceback:
ModuleNotFoundError: No module named 'PIL'In ComfyUI this can surface during startup, image loading, image saving, preview generation, metadata handling, or custom nodes that manipulate images.
Quick Diagnosis
| What You See | Meaning | First Action |
|---|---|---|
No module named 'PIL' | Pillow is missing from the active Python | Install Pillow |
pip install PIL fails | Wrong package name | Use pip install Pillow |
| Image nodes fail but models exist | Python imaging dependency is missing | Fix Pillow before moving model files |
| Error remains after install | Wrong Python was repaired | Run pip show Pillow through ComfyUI's Python |
Step 1: Check The Active Environment
Windows portable:
.\python_embeded\python.exe -s -c "import sys; print(sys.executable)"
.\python_embeded\python.exe -s -m pip show PillowManual venv:
python -c "import sys; print(sys.executable)"
python -m pip show PillowThe path must match the Python that starts ComfyUI.
Step 2: Install Pillow
Windows portable:
.\python_embeded\python.exe -s -m pip install PillowManual venv:
python -m pip install PillowThen verify the import:
.\python_embeded\python.exe -s -c "from PIL import Image; print(Image.__name__)"Step 3: Restart ComfyUI
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-buildIf a new missing package appears, that means the repair chain moved forward. Continue one package at a time instead of guessing a long install command.
What Not To Do
- do not install
PIL; installPillow - do not move image files or model files for a Python import error
- do not install into system Python when ComfyUI uses
python_embeded - do not downgrade Pillow unless a specific plugin compatibility note requires it
- do not repair Pillow and Torch/CUDA at the same time; verify one change before the next
Related Guides
- No module named 'yaml' in ComfyUI
- Repair ComfyUI Portable Dependencies One Missing Module At A Time
- Fix No module named errors in ComfyUI
- ComfyUI Dependency Conflicts
- Plugin Missing Module Warning: When It Is Safe to Ignore
Source References
- Windows portable SEO Lab repair, May 18, 2026:
ModuleNotFoundError: No module named 'PIL'appeared after installingPyYAML - Same lab cleanup action:
pip install Pillowmoved the startup log to the next missing dependency - Pillow on PyPI
Start free with Wonderful Launcher if this affects your real ComfyUI environment. It keeps launcher-native repair, task logs, and runtime checks in one place; credits are only for image generation and metered tools.
Download Wonderful LauncherSee credit packagesDid this fix your issue?
Your answer helps prioritize verified ComfyUI repairs.