ComfyUI ModuleNotFoundError / "No module named" — custom node won't import
Also seen as: "ModuleNotFoundError", "No module named", "ImportError", "cannot import"
Direct answer
How do I fix "ModuleNotFoundError"?
A ModuleNotFoundError at ComfyUI startup almost always means a custom node's Python dependency didn't install — the node folder is there, but a package it imports is missing.
Key facts
- iA custom node's requirements.txt never ran (headless installs skip it).
- iA from-source build (sam2, llama-cpp-python, insightface) failed or timed out.
- iPython/torch version mismatch — a wheel built for a different version.
Next step
- 1Reinstall the node's requirements: pip install -r custom_nodes/<node>/requirements.txt.
- 2For from-source packages, use --prefer-binary and a longer build timeout, or a prebuilt wheel.
- 3Paste the workflow into a checker that resolves each node to its repo + install command before you deploy.
- 4Match torch/CUDA versions to what the node was built against.
If that didn't fix it
- Reinstalling the node folder won't help if the missing package is a system build dependency.
Not sure this workflow will run before you rent a GPU?
Paste your ComfyUI workflow JSON into the free checker — it flags missing nodes, model requirements, and the VRAM/GPU you actually need. No signup.
Other ComfyUI errors
Frequently Asked Questions
What causes "ModuleNotFoundError" in ComfyUI?
A custom node's requirements.txt never ran (headless installs skip it).
How do I fix "ModuleNotFoundError"?
Reinstall the node's requirements: pip install -r custom_nodes/<node>/requirements.txt. For from-source packages, use --prefer-binary and a longer build timeout, or a prebuilt wheel.