ningxiaoxiao / comfyui-NDI

NDI input and output functionality to the ComfyUI.
GNU General Public License v3.0
49 stars 5 forks source link

[Import Error] ModuleNotFoundError: No module named 'cv2' #3

Closed superpeachman closed 8 months ago

superpeachman commented 8 months ago

Hi,

I installed comfyui-NDI from Comfy Manager. Then, I started to get this import error when I launched ComfyUI. I also installed comfyui-NDI from Git clone in my "custom_nodes" directory (after uninstalling comfyui-NDI by Comfy Manager), but I still got the same import error.

### ComfyUI Revision: 1880 [7c9a0f7e] | Released on '2024-01-05'
FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json
Traceback (most recent call last):
  File "C:\Users\XXXX\Documents\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1810, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\XXXX\Documents\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-NDI\__init__.py", line 7, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

Certainly, my Python environment of ComfyUI installed "opencv-python."

** Python executable: C:\Users\XXXX\Documents\ComfyUI_windows_portable\python_embeded\python -m pip list

Package            Version
------------------ ------------
certifi            2023.5.7
charset-normalizer 3.1.0
...
ndi-python         5.1.1.1
opencv-python      4.9.0.80
superpeachman commented 8 months ago

Sorry, it was my fault. The importing was done successfully.

I have struggled to install ndi-python to my ComfyUI python environment (Windows.) This error was related to the matter.

Just a piece of information for those new to ComfyUI, like me...

  1. I had an error when installing "ndi-python" to my ComfyUI python environment (Windows) by "pip install ndi-python" and couldn't finish installing it.

  2. So, I "Built with setup.py" along with instructions on the README.md. https://github.com/buresu/ndi-python (I recommend checking whether the Python version on your "Global" (if you use it for the build) and the Python version on your "ComfyUI" are the same. Built with 3.10 did not work on my ComfyUI, but built with 3.11 works now.)

  3. Then, I copied the NDIlib directory to "/ComfyUI_windows_portable\python_embeded\Lib\site-packages/" (as rastinder says here... Very thanks...) https://github.com/buresu/ndi-python/issues/31

moebiussurfing commented 1 month ago

Hey @superpeachman @ningxiaoxiao I followed your steps but I do not see the NDIlibfolder... Better said, that folder only have a 'init.py' file. Do you mean to copy 'D:\ndi-python\build\NDIlib.dir' or related instead? Thanks!

PS D:\ndi-python> python setup.py build
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-310
creating build\lib.win-amd64-cpython-310\NDIlib
copying NDIlib\__init__.py -> build\lib.win-amd64-cpython-310\NDIlib
running build_ext
cmake .. -DCMAKE_INSTALL_PREFIX=D:\ndi-python\build\install
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.26120.
-- The C compiler identification is MSVC 19.42.34226.3
-- The CXX compiler identification is MSVC 19.42.34226.3
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.42.34226/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.42.34226/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at lib/pybind11/CMakeLists.txt:8 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- pybind11 v2.9.2
CMake Warning (dev) at lib/pybind11/tools/FindPythonLibsNew.cmake:98 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  lib/pybind11/tools/pybind11Tools.cmake:50 (find_package)
  lib/pybind11/tools/pybind11Common.cmake:206 (include)
  lib/pybind11/CMakeLists.txt:200 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PythonInterp: C:/Users/moebi/AppData/Local/Microsoft/WindowsApps/python3.11.exe (found version "3.11.9")
-- Found PythonLibs: C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0/libs/python311.lib
-- Performing Test HAS_MSVC_GL_LTCG
-- Performing Test HAS_MSVC_GL_LTCG - Success
-- Found NDI: C:/Program Files/NDI/NDI 6 SDK
-- Configuring done (9.2s)
-- Generating done (0.0s)
-- Build files have been written to: D:/ndi-python/build
cmake --build . --config Release --target install
MSBuild version 17.12.0-preview-24402-01+bd46115a1 for .NET Framework

  1>Checking Build System
  Building Custom Rule D:/ndi-python/CMakeLists.txt
  main.cpp
     Creating library D:/ndi-python/build/Release/NDIlib.lib and object D:/ndi-python/build/Release/NDIlib.exp
  Generating code
  Finished generating code
  NDIlib.vcxproj -> D:\ndi-python\build\Release\NDIlib.cp311-win_amd64.pyd
  Building Custom Rule D:/ndi-python/CMakeLists.txt
  1>
  -- Install configuration: "Release"
  -- Installing: D:/ndi-python/build/install/NDIlib.cp311-win_amd64.pyd
  -- Installing: D:/ndi-python/build/install/Processing.NDI.Lib.x64.dll
  -- Installing: D:/ndi-python/build/install/Processing.NDI.Lib.Licenses.txt
moebiussurfing commented 1 month ago

image

moebiussurfing commented 1 month ago

Ok. it working placing files like that:

image