ComfyUI: ModuleNotFoundError: No module named 'transformers' (fix)
ModuleNotFoundError: No module named 'transformers' stops ComfyUI during startup, before any custom node loads. We reproduced it on ComfyUI v0.37.0, fixed it, and checked whether an old transformers version causes it too.
1. The error
ComfyUI v0.37.0 started in a venv where everything from requirements.txt is installed except transformers:
python main.py
File "/path/to/ComfyUI/main.py", line 251, in <module>
import execution
File "/path/to/ComfyUI/execution.py", line 18, in <module>
import comfy.model_patcher
File "/path/to/ComfyUI/comfy/model_patcher.py", line 33, in <module>
import comfy.hooks
File "/path/to/ComfyUI/comfy/hooks.py", line 14, in <module>
import comfy.lora
File "/path/to/ComfyUI/comfy/lora.py", line 22, in <module>
import comfy.model_base
File "/path/to/ComfyUI/comfy/model_base.py", line 79, in <module>
import comfy.ldm.hidream_o1.model
File "/path/to/ComfyUI/comfy/ldm/hidream_o1/model.py", line 20, in <module>
from comfy.text_encoders.qwen35 import Qwen35VisionModel
File "/path/to/ComfyUI/comfy/text_encoders/qwen35.py", line 16, in <module>
from comfy import sd1_clip
File "/path/to/ComfyUI/comfy/sd1_clip.py", line 3, in <module>
from transformers import CLIPTokenizer
ModuleNotFoundError: No module named 'transformers'
ComfyUI exited with code 1 before loading any nodes. transformers is not optional: comfy/sd1_clip.py imports its CLIPTokenizer at line 3, and the text encoders (Flux, Cosmos, Genmo and others) import its tokenizers too. It is listed in ComfyUI's requirements.txt as transformers>=4.50.3, so this error means that file was never installed into the Python that runs ComfyUI.
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 transformers>=4.50.3 (from -r requirements.txt (line 10))
Downloading transformers-5.20.2-py3-none-any.whl.metadata (31 kB)
Downloading transformers-5.20.2-py3-none-any.whl (12.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.8/12.8 MB 18.0 MB/s 0:00:00
Installing collected packages: transformers
Successfully installed transformers-5.20.2
Only transformers was missing, so only transformers was installed. 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.
If pip install reports transformers as 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 and use the right one.
3. What about an old transformers version?
We also tried transformers 4.49.0, one release below ComfyUI's minimum (pip pulled tokenizers 0.21.4 and huggingface-hub 0.36.2 with it). ComfyUI v0.37.0 still started and exited 0 with no IMPORT FAILED lines, so an old version does not cause this error at startup. Still, use what requirements.txt asks for; we did not test loading models with it.
Related: ComfyUI: No module named 'torchsde' · ComfyUI: No module named 'av' · ComfyUI: No module named 'sqlalchemy' · ComfyUI: No module named 'requests'
Frequently asked questions
Is transformers required by ComfyUI?
Yes. comfy/sd1_clip.py imports CLIPTokenizer from it, and requirements.txt lists transformers>=4.50.3. Without it ComfyUI exits with code 1 at startup.
I installed transformers but still get the error. Why?
It went into a different Python. Run pip as python -m pip with the same python (or python_embeded\python.exe) 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 transformers, after pip install -r requirements.txt (transformers 5.20.2), and with transformers 4.49.0. Output pasted unedited except shortened paths. PlainTables is our extension; ComfyUI and transformers are free.