ModuleNotFoundError: No module named 'onnx' or 'onnxruntime' in ComfyUI
Fix ModuleNotFoundError: No module named 'onnx' or 'onnxruntime' in ComfyUI, including onnxruntime.capi, WanVideoWrapper FantasyPortrait, DWPose, ReActor, IPAdapter FaceID, InstantID, and PuLID workflows.
No module named 'onnx' and No module named 'onnxruntime' appear when an ONNX-backed face, pose, or helper node cannot import its backend. First check whether the failing workflow actually uses ONNX nodes. onnx loads .onnx model files; onnxruntime runs them — they are related but not the same, and not every workflow needs both.
WanVideoWrapper WARNING: FantasyPortrait nodes not available: No module named 'onnx'
No module named 'onnxruntime'
ModuleNotFoundError: No module named 'onnxruntime.capi'
DWPose: Onnxruntime not found or doesn't come with acceleration providers, switch to OpenCV with CPU deviceCustom nodes that may need ONNX / ONNX Runtime include ComfyUI-WanVideoWrapper (FantasyPortrait), comfyui_controlnet_aux (DWPose), ComfyUI-ReActor, ComfyUI_IPAdapter_plus, ComfyUI_InstantID, and ComfyUI-PuLID. When missing, those nodes are unavailable while the rest of ComfyUI still works.
Severity: medium — install only if your workflow uses ONNX-backed pose, face, or helper models. A warning from an optional node family you do not use can be ignored.
Triage: pick the right ONNX branch
| Your newest error says | What it points to | Safer first fix |
|---|---|---|
No module named 'onnx' | Cannot parse/use ONNX model metadata | Install onnx in the ComfyUI Python |
No module named 'onnxruntime' | Cannot run ONNX inference | Install CPU onnxruntime first unless GPU ONNX is required |
No module named 'onnxruntime.capi' | ONNX Runtime missing, broken, or shadowed | Reinstall one ONNX Runtime package in the active Python |
LoadLibrary failed ... onnxruntime_providers_cuda.dll | GPU ONNX Runtime provider mismatch | Match ONNX Runtime GPU with CUDA/cuDNN/PyTorch; do not keep reinstalling |
| DWPose falls back / ONNX acceleration unavailable | Pose preprocessor can run CPU mode | Use CPU mode first, optimize only if too slow |
Both onnxruntime and onnxruntime-gpu installed | Conflicting runtime packages | Keep only one runtime package |
Stay anchored to the newest error. Do not switch to an older package family just because a previous log line mentioned a different plugin.
Need a safer repair path?
If this error is blocking real work, preserve the task logs and use the launcher-native diagnostics path before trying more blind package installs.
Open diagnostics pathUse the correct Python
| Install type | Command pattern |
|---|---|
| Official GitHub Windows portable package | From the portable package root: .\python_embeded\python.exe -s -m pip ... |
| Manual Git + venv install | Activate the venv, then run python -m pip ... |
| ComfyUI Desktop or managed launcher | Use the app's environment/terminal tools. Do not assume a portable python_embeded folder exists. |
Plain pip install from a random terminal is the most common reason the error stays. If a tool asks for a package name, enter onnxruntime or onnx, not pip install onnxruntime.
Option 1: Install the CPU version (safest first choice)
python -m pip install onnx onnxruntimeFor the official Windows portable package:
.\python_embeded\python.exe -s -m pip install onnx onnxruntimeThis is enough for many use cases; features like DWPose work in CPU mode, just slower.
Option 2: Install the GPU version
For an NVIDIA GPU where the workflow benefits from ONNX Runtime GPU acceleration:
python -m pip install onnx onnxruntime-gpuDo not keep both onnxruntime and onnxruntime-gpu installed. If you had the CPU package, remove it first:
python -m pip uninstall onnxruntime -y
python -m pip install onnxruntime-gpuCommon installation issues
GPU not working after installing onnxruntime-gpu:
[W:onnxruntime:Default, onnxruntime_pybind_state.cc] LoadLibrary failed with error 126 when trying to load onnxruntime_providers_cuda.dllThe CUDA/cuDNN family required by onnxruntime-gpu does not match PyTorch's runtime stack. Use CPU onnxruntime unless the workflow is clearly bottlenecked by ONNX inference; if you need GPU, match ONNX Runtime GPU to your PyTorch CUDA/cuDNN family instead of installing the latest package blindly.
Both onnxruntime and onnxruntime-gpu installed: check with python -m pip list | findstr onnxruntime, then keep only the one you need:
python -m pip uninstall onnxruntime onnxruntime-gpu -y
python -m pip install onnxruntimeprotobuf version conflict (TypeError: Descriptors cannot be created directly.) — quote the requirement so shells do not interpret >:
python -m pip install "protobuf>=3.20"Verify
python -c "import onnxruntime as ort; print(ort.__version__, ort.get_available_providers())"If GPU acceleration works, CUDAExecutionProvider appears. If only CPUExecutionProvider appears, the CPU package is installed or the GPU provider did not load.
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.