ComfyUI: ModuleNotFoundError: No module named 'PIL' (fix)
ModuleNotFoundError: No module named 'PIL' stops ComfyUI at startup, before any model or custom node loads. We reproduced it on ComfyUI v0.37.0 and fixed it.
1. The error
ComfyUI v0.37.0 started in a venv where everything from requirements.txt is installed except Pillow:
python main.py
Traceback (most recent call last):
File "/path/to/ComfyUI/main.py", line 35, in <module>
from comfy_execution.progress import get_progress_state
File "/path/to/ComfyUI/comfy_execution/progress.py", line 3, in <module>
from PIL import Image
ModuleNotFoundError: No module named 'PIL'
ComfyUI exited with code 1 before loading any nodes: main.py line 35 imports comfy_execution/progress.py, which does from PIL import Image at line 3. PIL is the import name of the Pillow package, which is listed in ComfyUI's requirements.txt, so seeing it missing usually means the requirements were never installed into the Python that runs ComfyUI, or something uninstalled it.
2. Fix: install requirements.txt with the same Python
From the ComfyUI folder, using the Python that starts ComfyUI (your venv's python; in the Windows portable build, ..\python_embeded\python.exe run from inside the ComfyUI folder):
python -m pip install -r requirements.txt
Collecting Pillow (from -r requirements.txt (line 17))
Downloading pillow-13.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (9.1 kB)
Downloading pillow-13.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.1/7.1 MB 23.7 MB/s 0:00:00
Installing collected packages: Pillow
Successfully installed Pillow-13.0.0
(pip also printed a dependency warning about an unrelated custom node package in our test venv; we left it out.) Started again, ComfyUI loaded all nodes and exited 0 (--quick-test-for-ci):
[INFO] Context impl SQLiteImpl.
[INFO] Will assume non-transactional DDL.
[INFO] Using RAM pressure cache.
3. Don't run pip install PIL
The package name differs from the import name. Asking pip for PIL finds nothing:
python -m pip install PIL
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
Install Pillow (or the whole requirements.txt, as above) and keep importing it as PIL.
If pip says Pillow is already installed and the error stays, you are installing into a different Python than the one running ComfyUI. See ComfyUI: No module named 'yaml' for how to find the right one.
Related: ComfyUI: No module named 'aiohttp' · ComfyUI: No module named 'einops' · ComfyUI: No module named 'safetensors' · ComfyUI: No module named 'transformers' · ComfyUI: No module named 'requests' · ComfyUI: No module named 'sqlalchemy'
Frequently asked questions
Is Pillow required by ComfyUI?
Yes. Pillow is in requirements.txt and comfy_execution/progress.py imports it (as PIL) during startup, so ComfyUI exits with code 1 without it.
Why does pip install PIL fail?
PIL is only the import name. The package on PyPI is Pillow: run python -m pip install Pillow with the Python that starts ComfyUI.
Written with AI assistance. Measured on 2026-10-24 on Linux, CPython 3.11.17, pip 26.2.2: ComfyUI v0.37.0 with torch 2.9.0+cpu, without Pillow and after pip install -r requirements.txt (Pillow 13.0.0). Output pasted unedited except shortened paths, omitted already-satisfied lines and one omitted pip warning. PlainTables is our extension; ComfyUI and Pillow are free.