No module named 'transformers' in ComfyUI
Fix ComfyUI No module named transformers errors in the active Python environment and understand when the failure comes from ComfyUI's core text stack.
You can fix it manually, or download Wonderful Launcher for Windows to diagnose plugin errors, missing dependencies, and broken ComfyUI environments without reinstalling.
Download free for WindowsIf ComfyUI stops with ModuleNotFoundError: No module named 'transformers', do not assume it is only a plugin problem.
In current ComfyUI builds, this error can come from ComfyUI's own text and tokenizer stack. In the tested portable repair lab, the traceback ran through comfy\sd1_clip.py and failed on from transformers import CLIPTokenizer before the server started.
Fast answer
For the GitHub Windows portable package:
.\python_embeded\python.exe -s -m pip show transformers tokenizers
Get-Content ComfyUI\requirements.txt | Select-String "transformers|tokenizers"
.\python_embeded\python.exe -s -m pip install transformers
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-buildIf the next startup fails on another core package, keep fixing the first new blocker in the same environment instead of switching to unrelated package commands.
What The Real Log Looked Like
In the repaired lab, the relevant part of the traceback looked like this:
File "...\ComfyUI\comfy\sd1_clip.py", line 3, in <module>
from transformers import CLIPTokenizer
ModuleNotFoundError: No module named 'transformers'That is not a random custom node path. It is ComfyUI's own model and tokenizer import path.
Quick Diagnosis
| What You See | Meaning | First Action |
|---|---|---|
No module named 'transformers' from comfy\sd1_clip.py | Core text/tokenizer dependency missing | Install transformers in ComfyUI's active Python |
pip show transformers works in system Python but ComfyUI still fails | Wrong Python environment | Use python_embeded\python.exe or the active venv |
Local requirements.txt lists transformers>=... and tokenizers>=... | ComfyUI expects this package family | Repair it from the same environment |
Installing transformers exposes a new missing package | Wider dependency drift | Keep following the new first blocker |
Server already starts and only a plugin fails on transformers | Could be plugin-specific | Still install into the same ComfyUI Python first |
Step 1: Check The Local Requirement Line
In the tested lab, ComfyUI\requirements.txt included:
transformers>=4.50.3
tokenizers>=0.13.3Check your local copy:
Get-Content ComfyUI\requirements.txt | Select-String "transformers|tokenizers"That tells you whether your ComfyUI code already expects the package.
Step 2: Install In The Python That Launches ComfyUI
For Windows portable:
.\python_embeded\python.exe -s -m pip install transformersFor a manual venv:
python -m pip install transformersIn the tested lab, this also pulled the adjacent package family automatically, including tokenizers, huggingface-hub, and regex.
If you are using ComfyUI Desktop or another managed launcher, install through that app's environment, not a separate terminal Python.
Step 3: Restart And Read The Next Blocker
Relaunch ComfyUI:
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-buildIn the lab, transformers was not the last missing package. After that import was repaired, the next first blocker became:
ModuleNotFoundError: No module named 'torchsde'That is normal in a broken portable environment. The right move is not to guess ten more packages. The right move is to fix the next first blocker in the same Python.
Step 4: Distinguish Core Failure From Plugin Failure
If the traceback points into:
ComfyUI\comfy\sd1_clip.pyComfyUI\comfy\supported_models.pyComfyUI\comfy\sd.py
then the missing transformers import is part of ComfyUI's own text stack.
If the traceback points into a custom node folder under custom_nodes, it may be plugin-specific. Even then, the repair still belongs in the same Python environment that launches ComfyUI.
What Not To Do
- do not install
transformersinto system Python when ComfyUI usespython_embeded - do not start by downgrading Torch, NumPy, or Pillow when the first visible error is only a missing
transformersimport - do not assume a plugin error means core ComfyUI is healthy until you read the traceback path
- do not keep installing packages without restarting and reading the new first blocker
How Wonderful Launcher Helps
When a tokenizer or model-stack import fails, the hard part is often proving which Python actually launched ComfyUI and whether the traceback came from core code or a plugin. Wonderful Launcher helps by keeping that environment boundary visible.
Related Guides
- ComfyUI 便携版依赖损坏后,按一个报错一个包修启动
- ModuleNotFoundError: No module named 'torch' in ComfyUI
- comfyui-frontend-package is not installed in ComfyUI
- ComfyUI Startup Failed
- Plugin Missing Module Warning: When It Is Safe to Ignore
Source References
- Windows portable repair lab, May 18, 2026: traceback failed on
from transformers import CLIPTokenizerinComfyUI\comfy\sd1_clip.py - Same lab
ComfyUI\requirements.txt:transformers>=4.50.3andtokenizers>=0.13.3 - Same lab next blocker after repair:
ModuleNotFoundError: No module named 'torchsde'
You can fix it manually, or download Wonderful Launcher for Windows to diagnose plugin errors, missing dependencies, and broken ComfyUI environments without reinstalling.
Download free for WindowsYou can fix it manually, or download Wonderful Launcher for Windows to diagnose plugin errors, missing dependencies, and broken ComfyUI environments without reinstalling.
Download free for WindowsDid this fix your issue?
Your answer helps prioritize verified ComfyUI repairs.
Torch Missing
Fix ComfyUI No module named torch errors in portable, venv, and managed installs, then verify that the repaired Torch build still has CUDA.
ONNX Missing
Fix No module named 'onnx' or 'onnxruntime' errors in ComfyUI for WanVideoWrapper, DWPose, ReActor, IPAdapter FaceID, InstantID, and PuLID workflows.