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 package maintainers publish standard and contrib builds, each with GUI and headless variants. All use the same cv2 namespace, so they explicitly direct users to select only one distribution per environment. A headless build omits OpenCV GUI features such as cv2.imshow; a browser UI does not by itself require those features. Maintainer installation and FAQ

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. Record the four distribution results and the affected node's requirements before changing packages. If a trusted cv2 already imports, inspect cv2.__file__ in that interpreter to identify the loaded copy; a manually placed old cv2 file can conflict even when package metadata looks clean. The maintainer recommends removing such an old manual binding before reinstalling. Maintainer guidance

Separate absence from native loading

For No module named cv2, inspect interpreter selection, installed distribution and import path. For Windows DLL load failed, preserve the full error and check the maintainer's platform-specific prerequisites, including the supported Visual C++ runtime and, for N/KN editions, Media Feature Pack; those are conditional checks, not universal fixes. Do not replace system DLLs with files from an unrelated download site. Maintainer FAQ

When duplicate distributions are present, preserve a recoverable environment copy and the node dependency record before cleanup. The maintainer's documented repair is to uninstall the conflicting OpenCV distributions and reinstall one selected flavor; test that sequence in the copy first. A package import is only an intermediate check: restart the same ComfyUI instance and rerun the original image-processing node. Record GUI-window failures separately from image-reading failures. Maintainer guidance

Source review completed 2026-09-26. No local package change, native import, image-node run or GPU reproduction was performed.

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

2026-09-26 reviewed current OpenCV Python maintainer PyPI installation and FAQ; English source review only. No local package, native import, node or GPU run.

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

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