if-ai / ComfyUI-IF_AI_tools

ComfyUI-IF_AI_tools is a set of custom nodes for ComfyUI that allows you to generate prompts using a local Large Language Model (LLM) via Ollama. This tool enables you to enhance your image generation workflow by leveraging the power of language models.
https://ko-fi.com/impactframes
366 stars 27 forks source link

Fail to import after latest update #16

Closed Niutonian closed 2 months ago

Niutonian commented 2 months ago

Hello, the latest upgrade gives me this error

..requirement already satisfied: mpmath>=0.19 in e:\comfyui\comfyui_windows_portable12_1\python_embeded\lib\site-packages (from sympy->torch==2.1.2+cu121->torchaudio->-r requirements.txt (line 1)) (1.3.0)
Collecting ruamel.yaml.clib>=0.2.7 (from ruamel.yaml>=0.17.28->hyperpyyaml->speechbrain<1.0->WhisperSpeech->-r requirements.txt (line 25))
  Using cached ruamel.yaml.clib-0.2.8-cp311-cp311-win_amd64.whl.metadata (2.3 kB)
Using cached av-12.0.0-cp311-cp311-win_amd64.whl (26.3 MB)
Using cached nltk-3.8.1-py3-none-any.whl (1.5 MB)
Using cached WhisperSpeech-0.8-py3-none-any.whl (62 kB)
Using cached speechbrain-0.5.16-py3-none-any.whl (630 kB)
Using cached fastcore-1.5.29-py3-none-any.whl (67 kB)
Using cached fastprogress-1.0.3-py3-none-any.whl (12 kB)
Using cached vocos-0.1.0-py3-none-any.whl (24 kB)
Using cached HyperPyYAML-1.2.2-py3-none-any.whl (16 kB)
Using cached ruamel.yaml-0.18.6-py3-none-any.whl (117 kB)
Using cached ruamel.yaml.clib-0.2.8-cp311-cp311-win_amd64.whl (118 kB)
Building wheels for collected packages: dlib
  Building wheel for dlib (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for dlib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      running bdist_wheel
      running build
      running build_ext

      ERROR: CMake must be installed to build dlib

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for dlib
Failed to build dlib
ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects
  File "E:\COMFYUI\ComfyUI_windows_portable12_1\ComfyUI\custom_nodes\ComfyUI-IF_AI_tools\__init__.py", line 10, in <module>
    from .IFDreamTalkNode import IFDreamTalk
  File "E:\COMFYUI\ComfyUI_windows_portable12_1\ComfyUI\custom_nodes\ComfyUI-IF_AI_tools\IFDreamTalkNode.py", line 20, in <module>
    from .dreamtalk.core.utils import (
  File "E:\COMFYUI\ComfyUI_windows_portable12_1\ComfyUI\custom_nodes\ComfyUI-IF_AI_tools\dreamtalk\core\utils.py", line 14, in <module>
    import dlib
ModuleNotFoundError: No module named 'dlib'

Cannot import E:\COMFYUI\ComfyUI_windows_portable12_1\ComfyUI\custom_nodes\ComfyUI-IF_AI_tools module for custom nodes: No module named 'dlib'

I guess it has problem running dlib, hope it can be saved.

if-ai commented 2 months ago

Hi thank you, installing dlib is tricky sometimes activate your comfy environment if pip install dlib --verbose does not work run sudo apt-get install cmake try again if it still doesn't work go to https://github.com/davisking/dlib clone the repo to any location git clone https://github.com/davisking/dlib.git got to the root of the repo and run sudo python3 setup.py install while your comfy env is active

Niutonian commented 2 months ago

@if-ai hey, thanks a lot for your quick answer, I'm using windows right now, do you know how to activate Comfyui environment?

if-ai commented 2 months ago

maybe like this ComfyUI\venv\Scripts\activate.bat there is also a bat file that should install everything if you got the portable vers all it does is somth like H:\ComfyUI_windows_portable\python_embeded\python.exe -m pip install -r requirements.txt

el3ctr0de commented 2 months ago

I got the same error today in the dreamtalk node, windows 10 portable comfyui, dlib refuses to install, I tried manually installing it, even installed CMake and visual studio build tools, still no luck. possibly an issue with using the embedded python?

if-ai commented 2 months ago

I got the same error today in the dreamtalk node, windows 10 portable comfyui, dlib refuses to install, I tried manually installing it, even installed CMake and visual studio build tools, still no luck. possibly an issue with using the embedded python?

I have it working on embedded python windows 10 too with H:\ComfyUI_windows_portable\python_embeded\python.exe -m pip install dlib maybe H:\ComfyUI_windows_portable\python_embeded\python.exe -m pip install cmake first or you could git clone the dilib repo git clone https://github.com/davisking/dlib.git cd dlib H:\ComfyUI_windows_portable\python_embeded\python.exe setup.py install

el3ctr0de commented 2 months ago

\ComfyUI_windows_portable\python_embeded\python.exe -m pip install cmake reports that cmake is installed.

\ComfyUI_windows_portable\python_embeded\python.exe -m pip install dlib produces the attached error. I also tried to build it from the github link and got the same error I think.

dlib-error.txt

if-ai commented 2 months ago

Did you try pip install --upgrade pip so you are on the latest pip? otherwise I think I will split whisper speech onto it's own repo, so people can still use the other nodes without dlib

el3ctr0de commented 2 months ago

yes, PS Z:\ComfyUI_windows_portable> .\python_embeded\Scripts\pip.exe install --upgrade pip Requirement already satisfied: pip in z:\comfyui_windows_portable\python_embeded\lib\site-packages (24.0)

MaarVFX commented 2 months ago

Same problem, dlib says cmake needs to be installed, while it IS already installed. Upgrading CMake didn't help, neither did upgrading pip. Still produces:

Building wheels for collected packages: dlib
  Building wheel for dlib (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for dlib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      running bdist_wheel
      running build
      running build_ext

      ERROR: CMake must be installed to build dlib

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for dlib
Failed to build dlib
ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects
Niutonian commented 2 months ago

@if-ai I have tried upgrading, pip, cmake, downloaded dlib from git and tried installing it, but even though cmake is installed, I still get this error

E:\COMFYUI\ComfyUI_windows_portable12_1\python_embeded\Lib\site-packages\setuptools\_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
E:\COMFYUI\ComfyUI_windows_portable12_1\python_embeded\Lib\site-packages\setuptools\_distutils\cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``easy_install``.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!
  self.initialize_options()
running bdist_egg
running egg_info
writing tools/python\dlib.egg-info\PKG-INFO
writing dependency_links to tools/python\dlib.egg-info\dependency_links.txt
writing top-level names to tools/python\dlib.egg-info\top_level.txt
reading manifest file 'tools/python\dlib.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tools\python\build*'
no previously-included directories found matching 'dlib\cmake_utils\*\build*'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
adding license file 'LICENSE.txt'
writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_ext

ERROR: CMake must be installed to build dlib
if-ai commented 2 months ago

DEDICATED ENV

Activate the env

on conda env conda install -c conda-forge dlib

on micromamba env micromamba install -c conda-forge dlib

open terminal as admin

pip uninstall cmake
pip uninstall dlib

WINDOWS

H:\ComfyUI_windows_portable\python_embeded\python.exe -m pip install cmake
H:\ComfyUI_windows_portable\python_embeded\python.exe -m pip install dlib

or activate env

python -m -m pip install cmake
python -m pip install dlib

if not try with the terminal as admin

pip uninstall cmake
pip uninstall dlib
pip install cmake
git clone https://github.com/davisking/dlib.git
cd dlib
H:\ComfyUI_windows_portable\python_embeded\python.exe setup.py install
ekondev commented 2 months ago

There is an error about visual studio in the middle. is it mandatory to have it?

K:\python_embeded>git clone https://github.com/davisking/dlib.git Cloning into 'dlib'... remote: Enumerating objects: 51600, done. remote: Counting objects: 100% (147/147), done. remote: Compressing objects: 100% (112/112), done. remote: Total 51600 (delta 64), reused 94 (delta 35), pack-reused 51453 Receiving objects: 100% (51600/51600), 48.14 MiB | 19.89 MiB/s, done. Resolving deltas: 100% (36443/36443), done. Updating files: 100% (2260/2260), done.

K:\python_embeded>cd dlib

K:\python_embeded\dlib>python setup.py install running install running bdist_egg running egg_info creating tools\python\dlib.egg-info writing tools/python\dlib.egg-info\PKG-INFO writing dependency_links to tools/python\dlib.egg-info\dependency_links.txt writing top-level names to tools/python\dlib.egg-info\top_level.txt writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt' adding license file 'LICENSE.txt' (matched pattern 'LICEN[CS]E') reading manifest file 'tools/python\dlib.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'tools\python\build' no previously-included directories found matching 'dlib\cmake_utils*\build' warning: no previously-included files matching '.pyc' found anywhere in distribution writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_ext Building extension for Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] Invoking CMake setup: 'cmake K:\python_embeded\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=K:\python_embeded\dlib\build\lib.win-amd64-3.9 -DPYTHON_EXECUTABLE=C:\Program Files\Python39\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=K:\python_embeded\dlib\build\lib.win-amd64-3.9 -A x64' -- Building for: NMake Makefiles CMake Error at CMakeLists.txt:5 (message):

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

You must use Visual Studio to build a python extension on windows. If you are getting this error it means you have not installed Visual C++. Note that there are many flavors of Visual Studio, like Visual Studio for C# development. You need to install Visual Studio for C++.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

-- Configuring incomplete, errors occurred! Traceback (most recent call last): File "K:\python_embeded\dlib\setup.py", line 220, in setup( File "C:\Program Files\Python39\lib\site-packages\setuptools__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "C:\Program Files\Python39\lib\distutils\core.py", line 148, in setup dist.run_commands() File "C:\Program Files\Python39\lib\distutils\dist.py", line 966, in run_commands self.run_command(cmd) File "C:\Program Files\Python39\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\Program Files\Python39\lib\site-packages\setuptools\command\install.py", line 67, in run self.do_egg_install() File "C:\Program Files\Python39\lib\site-packages\setuptools\command\install.py", line 109, in do_egg_install self.run_command('bdist_egg') File "C:\Program Files\Python39\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\Program Files\Python39\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\Program Files\Python39\lib\site-packages\setuptools\command\bdist_egg.py", line 164, in run cmd = self.call_command('install_lib', warn_dir=0) File "C:\Program Files\Python39\lib\site-packages\setuptools\command\bdist_egg.py", line 150, in call_command self.run_command(cmdname) File "C:\Program Files\Python39\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\Program Files\Python39\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\Program Files\Python39\lib\site-packages\setuptools\command\install_lib.py", line 11, in run self.build() File "C:\Program Files\Python39\lib\distutils\command\install_lib.py", line 107, in build self.run_command('build_ext') File "C:\Program Files\Python39\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "C:\Program Files\Python39\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "K:\python_embeded\dlib\setup.py", line 130, in run self.build_extension(ext) File "K:\python_embeded\dlib\setup.py", line 167, in build_extension subprocess.check_call(cmake_setup, cwd=build_folder) File "C:\Program Files\Python39\lib\subprocess.py", line 373, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', 'K:\python_embeded\dlib\tools\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=K:\python_embeded\dlib\build\lib.win-amd64-3.9', '-DPYTHON_EXECUTABLE=C:\Program Files\Python39\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=K:\python_embeded\dlib\build\lib.win-amd64-3.9', '-A', 'x64']' returned non-zero exit status 1.

if-ai commented 2 months ago

I move it the whisperSpeech which was creating the error to a new repo https://github.com/if-ai/ComfyUI-IF_AI_WishperSpeechNode

You must likely have the same issues to install it but at least now you can try the other nodes for the TTS part and you can always use other tts I have another one here https://github.com/if-ai/ComfyUI-IF_AI_ParlerTTSNode I also have a better explanation on how to install it over there but yes I think you will probs need VStudio as I have it already that might be why it installed it on the first try

brentjohnston commented 2 months ago

It seems like the problem was a whl doesn't exist for the comfyui python embedded 3.11 for dlib so you have to build it.

I was able to resolve this error by installing the same version of python comfyui embedded to system using to PATH option during setup. You can get your version portable version by typing python --version in comfyui folder.

Then install the cmake windows installer. Then visual studio installer and install all of the 2022 build tools options. Then I close down cmd window reopen it for \comfyui directory and run python.exe -m pip install dlib and it built it dlib without the error.

Then go to Comfyui folder \python_embeded and run python.exe -m pip install dlib

image

image

Edit: or to make this easier you can just copy the 3.11 whl I built to python_embedded and run python.exe -m pip install dlib-19.24.4-cp311-cp311-win_amd64.whl Make sure your portable is using same version of python as this .whl or do the steps above and build a new whl manually.