Reference only

Fix cv2 imports without stacking OpenCV distributions

Identify the installed OpenCV flavor before investigating missing modules or native-library loading.

One namespace, several distributions

The OpenCV maintainers publish standard and contrib builds, with GUI and headless variants. All provide cv2; their instructions say to choose one per environment.1

Inspect before changing anything:

python -m pip show opencv-python opencv-contrib-python opencv-python-headless opencv-contrib-python-headless

Use the interpreter behind the failing ComfyUI process. Our suggested next step is to compare the installed flavor with the dependency requirements of the nodes you actually use. A headless package is not automatically wrong just because ComfyUI has a browser interface.

Separate absence from native loading

For No module named cv2, investigate the import path and installation. For DLL load failed, retain the full exception chain and inspect the native-runtime requirements documented by the maintainer. Do not replace system DLLs with files from an unrelated download site.

When duplicate distributions are present, record them and test the cleanup in an environment copy. Installing another flavor on top is not the proposed repair. Validate the trusted package import, restart the same instance, and run the original image-processing node. Record GUI-window failures separately from image-reading failures.

Research draft. No local/GPU reproduction or independent editorial sign-off. Upstream statements and our recommendations are distinguished.

Didn't solve it?

Check the next possible cause

The same symptom can come from a different cause. Work through these related entries in order.

  1. No module named yaml, PIL or pydantic_settings: check the distribution nameNo module named yamlMatch the import name to its distribution before changing the Python environment that runs ComfyUI.
  2. MMCV installation and missing-operator errors: check the build combinationNo module named mmcvDistinguish full and lite distributions, source-build failures and runtime extension loading.
Paste your full log into the error finder

Was this page helpful?

Anonymous. Only a yes/no counter is stored; no account, IP address or device details.

Sources & references

Research draft. No local/GPU reproduction or independent editorial sign-off. Upstream statements and our recommendations are distinguished.

01OpenCV Python distribution maintainersSource checked: 2026-09-21

Report an issue · 42bb7c01-18fc-5d13-93f8-bd3901f831cd