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
Related checks
- No module named yaml, PIL or pydantic_settings: check the distribution name
- MMCV installation and missing-operator errors: check the build combination
Source review completed 2026-09-26. No local package change, native import, image-node run or GPU reproduction was performed.
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