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.
Related checks
- No module named yaml, PIL or pydantic_settings: check the distribution name
- MMCV installation and missing-operator errors: check the build combination
Research draft. No local/GPU reproduction or independent editorial sign-off. Upstream statements and our recommendations are distinguished.
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