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.
When ComfyUI prints ModuleNotFoundError: No module named ..., this hub routes you to the exact fix. The missing package is only half the diagnosis — the more important question is which Python environment launched ComfyUI.
For the official Windows portable package, run package commands 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 | 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 |
Route to the exact fix
| Missing module | Where it usually appears | Best next page |
|---|---|---|
triton | FLUX, acceleration stacks, mixed plugin/runtime environments | Fix triton |
sageattention | Performance-oriented workflows and acceleration plugins | Fix sageattention |
onnx / onnxruntime | Face, pose, upscaling, and ONNX-backed nodes | Fix onnx and onnxruntime |
llama_cpp | LLM or prompt-helper custom nodes | Fix llama_cpp |
groundingdino / segment_anything | Detection, segmentation, and grounding workflows | Fix SAM/GroundingDINO imports |
insightface | Face swap, face analysis, identity workflows | Fix insightface |
cv2 | OpenCV-dependent image and video nodes | Fix cv2 |
nunchaku (and nunchaku.lora / nunchaku.models) | Nunchaku quantized FLUX/Qwen/SANA workflows | Fix nunchaku |
kornia | Built-in post-processing, canny, and morphology nodes | Fix kornia |
spandrel | Upscale model nodes and nodes_upscale_model.py | Fix spandrel |
simpleeval | Math expression nodes and nodes_math.py | Fix simpleeval |
pydantic_settings | pyproject.toml parsing and settings imports | Fix pydantic_settings |
yaml / PIL | Package-name traps: install PyYAML / Pillow | Fix yaml or fix PIL |
safetensors | Python package for reading safetensors files | Fix the safetensors package |
einops | Core tensor/model utilities and ML custom nodes | Fix einops |
scipy | Scientific Python stack, audio/video/model utilities | Fix scipy |
torchsde | PyTorch-adjacent sampler/model stack | Fix torchsde |
av | PyAV media/video dependency | Fix av |
aiohttp / requests | Server and HTTP client dependencies | Fix aiohttp or fix requests |
If the missing module is not listed (for example argostranslate, flash_attn, dlib, soundfile, timm, nvvfx, decord, hydra), repair the custom node that imports it rather than installing a package by guessing its name.
No OpenGL_accelerate module loaded is usually not a startup failure
No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate'OpenGL_accelerate comes from PyOpenGL-accelerate, an optional performance companion for PyOpenGL. If the same log later shows Starting server and To see the GUI go to: http://127.0.0.1:..., ComfyUI started — do not install packages just to remove this warning. Install PyOpenGL-accelerate (into ComfyUI's Python) only when a named feature or traceback requires it. This is not the same as RuntimeError: OpenGL dependencies not available from nodes_glsl.py; for that, follow the OpenGL dependency guide.
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 comes from an OpenCV package, and segment_anything from segment-anything).
Step 2: Find the Python that starts ComfyUI
.\python_embeded\python.exe -s -m pip --version
.\python_embeded\python.exe -s -m pip show <package-name>For manual venv installs, use python -m pip .... The output path should point into the same ComfyUI environment; if it points to system Python, the repair is in the wrong place.
Step 3: Decide whether the missing package is fatal
| 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 |
Where the traceback starts changes the repair path: ComfyUI\comfy\... or bootstrap files mean a core dependency drifted (pair with Startup Failed); custom_nodes\<plugin>\... means repair that plugin only (pair with plugin import failures); a launcher deployment step means an install/bootstrap issue.
Step 4: Package name, pip command, or requirements file?
When a guide or repair tool asks for a package name, do not paste a whole shell command:
| You have | What it is | Safer handling |
|---|---|---|
onnxruntime | A package spec | Install it with the Python that starts ComfyUI |
pip install onnxruntime | A shell command | Run it in a terminal for the correct Python, or copy just onnxruntime into a package field |
python -m pip install onnxruntime | A Python/pip command | Use it as a command, not a package name |
requirements.txt | A dependency file | Install with pip install -r requirements.txt, not as a package named requirements.txt |
custom_nodes/MyNode/requirements.txt | A plugin dependency file | Install only for that plugin, then restart and check its import |
Do not install every related package at once. Restart after each repair and read the new first error.
Step 5: Verify the repair
.\python_embeded\python.exe -s -c "import <module_name>; print('import ok')"Then restart ComfyUI. The original ModuleNotFoundError should be gone and the affected node or workflow should load. If a new missing package appears, treat it as the next first blocker.
Stop and re-check before installing anything if the missing module changed after each restart, the install succeeded but the same name still fails, you are mixing system Python and python_embeded, Torch/CUDA/DLL errors appeared at the same time, or more than one plugin started failing after a single install. That pattern usually means the environment drifted, not that one package is missing in isolation.
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
- ComfyUI Dependency Conflicts
- How to Fix ComfyUI Plugin Import Failed Errors
- ComfyUI Python Embedded Explained
- Install Custom Nodes Safely
- Where to Put Safetensors in ComfyUI
Source References
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.