Fix No module named errors in ComfyUI
Diagnose ComfyUI ModuleNotFoundError and No module named errors by package name, Python environment, custom node dependency, and CUDA or PyTorch mismatch.
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 prints ModuleNotFoundError: No module named ..., the missing Python package is only part of the diagnosis. The more important question is which Python environment launched ComfyUI.
For the official Windows portable package, package commands usually need to run through:
.\python_embeded\python.exe -s -m pip ...For a manual Git install, activate the same virtual environment that starts ComfyUI, then use:
python -m pip ...Related errors
Fast Diagnosis
| What the log says | Most likely cause | First check |
|---|---|---|
ModuleNotFoundError from custom_nodes | A custom node dependency is missing | Read the plugin folder and its requirements.txt |
ModuleNotFoundError from ComfyUI\comfy\... | A core ComfyUI dependency is missing or drifted | Check local ComfyUI\requirements.txt |
pip install succeeds but the error remains | Installed into the wrong Python | Run pip show with ComfyUI's Python |
| Error changes after restart | You fixed the first blocker and exposed the next one | Continue with the new first traceback |
| CUDA, DLL, or wheel errors appear | Package has native or GPU dependencies | Check Torch/CUDA before changing more packages |
Step 1: Copy the Exact Missing Module
Start with the copied line, not the package you guessed:
ModuleNotFoundError: No module named 'sageattention'The import name and the pip package name are not always identical. For example, cv2 usually comes from an OpenCV package, and segment_anything comes from segment-anything.
Step 2: Find the Python That Starts ComfyUI
For Windows portable, run from the portable package root:
.\python_embeded\python.exe -s -m pip --version
.\python_embeded\python.exe -s -m pip show <package-name>For manual venv installs:
python -m pip --version
python -m pip show <package-name>The output path should point into the same ComfyUI environment. If it points to system Python, the repair is happening in the wrong place.
Step 3: Decide Whether the Missing Package Is Fatal
Not every missing optional acceleration package should be fixed immediately.
| Missing module | Often fatal? | Notes |
|---|---|---|
transformers from ComfyUI core | Yes | Core tokenizer/model stack may fail before startup |
torch | Yes | ComfyUI cannot run without a working PyTorch install |
cv2 | Often plugin-fatal | Many vision custom nodes need OpenCV |
sageattention | Often optional | Fix only if a workflow or launch flag requires it |
onnxruntime | Workflow-dependent | Face, pose, and ONNX-backed nodes may need it |
diffusers | Plugin-dependent | Usually a third-party node requirement |
Step 4: Install the Specific Fix
Use the specific guide when it exists:
- No module named 'sageattention'
- No module named 'cv2'
- No module named 'insightface'
- No module named 'onnx' or 'onnxruntime'
- No module named 'transformers'
- No module named 'torch'
- No module named 'triton'
Do not install every related package at once. Restart after each repair and read the new first error.
Step 5: Verify the Repair
Before restarting ComfyUI, verify the import in the same Python:
python -c "import <module_name>; print('import ok')"For Windows portable, use:
.\python_embeded\python.exe -s -c "import <module_name>; print('import ok')"Then restart ComfyUI. The original ModuleNotFoundError should be gone, and the affected custom node or workflow should load. If a new missing package appears, treat it as the next first blocker.
When Wonderful Launcher Is the Better Next Step
Manual package repair works when there is one clear missing import. It becomes risky when:
- several custom nodes fail at startup
pip checkreports conflicts after each install- CUDA or Torch changed while fixing a plugin
- you are not sure which Python launched ComfyUI
- the workflow matters and you need to preserve models and settings
Still stuck after the manual fix?
Preserve the environment, collect the startup log, and use Wonderful Launcher diagnostics as the next step instead of trying random package installs.
Open diagnostics pathRelated Guides
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.
ComfyUI Common Issues and Fast Fixes
Fast fixes for common ComfyUI problems — CUDA errors, red nodes, missing models, prompt has no outputs, slow generation, and reconnecting.
ComfyUI Dependency Conflicts: Fix Without Reinstalling
Fix ComfyUI dependency conflicts after custom node installs, Torch downgrades, pip clashes, or broken plugin imports without destroying a working environment.