ModelSurge / sd-webui-comfyui

An extension to integrate ComfyUI workflows into the Webui's pipeline
MIT License
504 stars 31 forks source link

comfyui install script does not install comfyui #149

Open ionutanton opened 1 year ago

ionutanton commented 1 year ago

Hi i get the following error when loading comfyui. using windows, version: [v1.5.1] •  python: 3.10.11  •  torch: 2.0.1+cu118  •  xformers: 0.0.20  •  gradio: 3.32.0  •  checkpoint: 6ce0161689

[ComfyUI] [sd-webui-comfyui] Setting up IPC...
[ComfyUI] [sd-webui-comfyui] Using inter-process communication strategy: Shared memory
[ComfyUI] [sd-webui-comfyui] Started callback listeners for process comfyui
[ComfyUI] [sd-webui-comfyui] Patching ComfyUI...
Traceback (most recent call last):
  File "E:\AI\automatic1111\stable-diffusion-webui\extensions\sd-webui-comfyui\lib_comfyui\comfyui\pre_main.py", line 93, in <module>
    main()
  File "E:\AI\automatic1111\stable-diffusion-webui\extensions\sd-webui-comfyui\lib_comfyui\ipc\__init__.py", line 41, in wrapper
    return function(*args, **kwargs)
  File "E:\AI\automatic1111\stable-diffusion-webui\extensions\sd-webui-comfyui\lib_comfyui\comfyui\pre_main.py", line 25, in main
    patch_comfyui()
  File "E:\AI\automatic1111\stable-diffusion-webui\extensions\sd-webui-comfyui\lib_comfyui\ipc\__init__.py", line 41, in wrapper
    return function(*args, **kwargs)
  File "E:\AI\automatic1111\stable-diffusion-webui\extensions\sd-webui-comfyui\lib_comfyui\comfyui\pre_main.py", line 79, in patch_comfyui
    paths.share_webui_folder_paths()
  File "E:\AI\automatic1111\stable-diffusion-webui\extensions\sd-webui-comfyui\lib_comfyui\ipc\__init__.py", line 41, in wrapper
    return function(*args, **kwargs)
  File "E:\AI\automatic1111\stable-diffusion-webui\extensions\sd-webui-comfyui\lib_comfyui\webui\paths.py", line 9, in share_webui_folder_paths
    from folder_paths import add_model_folder_path
ModuleNotFoundError: No module named 'folder_paths'
[ComfyUI] [sd-webui-comfyui] Stopped callback listeners for process comfyui
PladsElsker commented 1 year ago

What is your version of ComfyUI? Is it up to date?

ljleb commented 1 year ago

It looks like a pythonpath problem when starting the comfyui process. I want to know what sys.path looks like before running into this error. You can do this by adding a print statement before the line where the error occurs:

...
ipc.restrict_to_process('comfyui')
def share_webui_folder_paths():
    print(sys.path) # <- insert code here
    from folder_paths import add_model_folder_path
...

There should not be any sensitive information there as far as I know.

ionutanton commented 1 year ago

path looks like below

[ComfyUI] ['E:\\AI\\automatic1111\\stable-diffusion-webui\\extensions\\sd-webui-comfyui', 'E:\\AI\\automatic1111\\stable-diffusion-webui\\extensions\\sd-webui-comfyui\\lib_comfyui\\comfyui', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\\python310.zip', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\\DLLs', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\\lib', 'C:\\Users\\ionut\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0', 'E:\\AI\\automatic1111\\stable-diffusion-webui\\venv', 'E:\\AI\\automatic1111\\stable-diffusion-webui\\venv\\lib\\site-packages', 'E:\\AI\\automatic1111\\stable-diffusion-webui\\venv\\lib\\site-packages\\win32', 'E:\\AI\\automatic1111\\stable-diffusion-webui\\venv\\lib\\site-packages\\win32\\lib', 'E:\\AI\\automatic1111\\stable-diffusion-webui\\venv\\lib\\site-packages\\Pythonwin']
ionutanton commented 1 year ago

What is your version of ComfyUI? Is it up to date?

using the automatic1111 gui to install comfyUI. the gui reads vestion as: a332cfa3.

Vetrov0x commented 1 year ago

I have almost the same error, but it says: AttributeError: 'For' object has no attribute 'value' [ComfyUI] [sd-webui-comfyui] Stopped callback listeners for process comfyui

I already tried to reinstall Comfy within Automatic1111, but this error still persists. Backup doesn't help either

ljleb commented 1 year ago

What version of windows are you using @ionutanton?

I would appreciate if you could share the full logs @Vetrov0x as I can't trace back the error with just the error message. It could be a different issue as far as I know. If possible, some system information may help pin it down (i.e. python version, os, a1111 version, etc.).

I'm unable to reproduce locally on a windows 10 machine any of the reported issues. I thought this had to do with the PYTHONPATH environment variable but I'm not sure anymore. I'll try to put the path to comfyui at index 0 and see if that fixes the issue for you guys.

EDIT: Nevermind, I can reproduce the "for" issue. Working on a fix.

ljleb commented 1 year ago

It's caused by the newer version of comfyui now having a proper interface to add web extensions.

ljleb commented 1 year ago

@Vetrov0x the issue should be resolved. It was indeed a different issue, unrelated to this.

ionutanton commented 1 year ago

using Windows 11 Pro - 22621.2134

xianrenzhang0318 commented 1 year ago

[sd-webui-comfyui] Started callback listeners for process webui [Lobe]: Initializing Lobe Traceback (most recent call last): File "I:\sd-webui-aki\sd-webui-aki-v4\extensions\sd-webui-comfyui\lib_comfyui\comfyui\pre_main.py", line 7, in from lib_comfyui import ( ModuleNotFoundError: No module named 'lib_comfyui' Tip: An exception was thrown by the Python runtime. Please check the troubleshooting page

ionutanton commented 1 year ago

the problem is that i installed the extension via the AUTO1111 webui form the extension tab. while doing this the install script does not git clone the comfyUI. the folowing repaired the problem:

cmd into extensions\sd-webui-comfyui. git clone https://github.com/comfyanonymous/ComfyUI.git in that folder. changed the path in the settings: comfyui to point to the folder extensions\sd-webui-comfyui\ComfyUI.

all good now for me.

PeggyFree commented 1 year ago

@ionutanton I've done what you suggests but I'm struggling with the error mentioned by @xianrenzhang0318 :

ModuleNotFoundError: No module named 'lib_comfyui'

I've been trying to solve this for more than 3h...

ljleb commented 1 year ago

@PeggyFree it is possible that you are running into #148. I'm not sure what could be the cause, as the code explicitly appends to PYTHONPATH the appropriate module paths... I'm not 100% aware of the init procedure of a python interpreter, so the code may be missing some details that prevents sys.path from getting properly augmented.

PeggyFree commented 1 year ago

@ljleb thank you for your help. I just checked, my pythonpath already mentions the directory, I can't recall if it was already there or if I put it there by myself :

C:\Users\the_user\automatic\extensions\sd-webui-comfyui\lib_comfyui

I'm far to be an expert, do you suggest me rolling back to commit https://github.com/ModelSurge/sd-webui-comfyui/commit/d2ed1a98eac89858aecdbba27ffa01f522f8b045 as suggested in the other post?

PeggyFree commented 1 year ago

I tried to roll back to commit using the following command but I get another error.......

git reset --hard d2ed1a9

[ComfyUI] File "C:\Users\Franck\automatic\extensions\sd-webui-comfyui\lib_comfyui\custom_extension_injector.py", line 87, in patch_prompt_server_add_routes add_routes_ast_function.body[1].value.args[0].elts[0:0] = [extra_line_of_code.body[0].value] [ComfyUI] AttributeError: 'For' object has no attribute 'value'

I also tried reinstalling all sd.next + sd_web_comfyui from scratch but I get the same lib_comfyui error

ljleb commented 1 year ago

I just merged something that may or may not help. Please let us know if the latest version works any better.

ljleb commented 1 year ago

@PeggyFree I'm far to be an expert, do you suggest me rolling back to commit d2ed1a98eac89858aecdbba27ffa01f522f8b045 as suggested in the other post?

Unfortunately, commit d2ed1a98eac89858aecdbba27ffa01f522f8b045 does not work on newer versions of comfyui, so I would not recommend it if you use the latest comfyui update.

Vetrov0x commented 1 year ago

Automatic 1111 1.6.0 update broke the extention and the reinstallation doesnt helps. No error in terminal but the iframe in tabs doesn't show up. It works from browser tab however

Vetrov0x commented 1 year ago

I just tryed to revert to a previus version of the webui, but it does not reinstalled 1.5, it's still 1.6 but now the plugin is working 🤯

ljleb commented 1 year ago

The latest commit of the extension should work on 1.6.0.

If the iframes do not load, check the terminal and once the comfyui server finishes loading, click on the "reload comfyui interfaces" button in either the txt2img or img2img accordions.

If there are no error in console and the comfyui server loads, then this will likely fix it.

Vetrov0x commented 1 year ago

Oh wait, I figured out why it was working on 1.6, it's because of the fact that i'm trying to use Automatic on my PC from my mac via the network, and i got Automatic On on both computers, so the Automatic webui from my pc was showing the comfyui from my mac as the adress was 127.0.0.1 🤦

Reverting to the 1.5.2 solves the problem with comfyui, but I'm still trying to figure out how to get ComfyUI from my pc on my mac's webui. Tryed to add the IP address in settings but it doesnt work either, may be i'm doing something wrong.

ljleb commented 1 year ago

AFAIK this issue should be resolved on 1.6.0. I would like to know if anybody else is able to verify this, as I was not able to reproduce the initial problem on my system.

I changed the behavior of the client url in the settings so that any missing info is added. This makes it possible to put partial urls like localhost:8189 (missing protocol) or http://0.0.0.0 (missing port) or even localhost. Let us know if this resolved the problem for you @Vetrov0x

Vetrov0x commented 1 year ago

AFAIK this issue should be resolved on 1.6.0. I would like to know if anybody else is able to verify this, as I was not able to reproduce the initial problem on my system.

I changed the behavior of the client url in the settings so that any missing info is added. This makes it possible to put partial urls like localhost:8189 (missing protocol) or http://0.0.0.0 (missing port) or even localhost. Let us know if this resolved the problem for you @Vetrov0x

I ended up to delete all and reinstall all step by step from github and now it works. I think I might forgot a detail last time. Anyway thanks, you guys did a great job !

rugabunda commented 1 year ago

Same error, loading the latest release of comfyui, the version with unstable nightly pytorch

Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
[sd-webui-comfyui] Started callback listeners for process webui 
Startup time: 2.9s (load scripts: 1.4s, create ui: 0.9s, gradio launch: 0.1s, app_started_callback: 0.5s).
[ComfyUI] [sd-webui-comfyui] Setting up IPC...
[ComfyUI] [sd-webui-comfyui] Using inter-process communication strategy: Shared memory
[ComfyUI] [sd-webui-comfyui] Started callback listeners for process comfyui
[ComfyUI] [sd-webui-comfyui] Patching ComfyUI...
Traceback (most recent call last):
  File "D:\AI\Image\SD\extensions\sd-webui-comfyui\lib_comfyui\comfyui\pre_main.py", line 86, in <module>
    main()
  File "D:\AI\Image\SD\extensions\sd-webui-comfyui\lib_comfyui\ipc\__init__.py", line 41, in wrapper
    return function(*args, **kwargs)
  File "D:\AI\Image\SD\extensions\sd-webui-comfyui\lib_comfyui\comfyui\pre_main.py", line 41, in main
    patch_comfyui()
  File "D:\AI\Image\SD\extensions\sd-webui-comfyui\lib_comfyui\ipc\__init__.py", line 41, in wrapper
    return function(*args, **kwargs)
  File "D:\AI\Image\SD\extensions\sd-webui-comfyui\lib_comfyui\comfyui\pre_main.py", line 72, in patch_comfyui
    paths.share_webui_folder_paths()
  File "D:\AI\Image\SD\extensions\sd-webui-comfyui\lib_comfyui\ipc\__init__.py", line 41, in wrapper
    return function(*args, **kwargs)
  File "D:\AI\Image\SD\extensions\sd-webui-comfyui\lib_comfyui\webui\paths.py", line 9, in share_webui_folder_paths
    from folder_paths import add_model_folder_path
ModuleNotFoundError: No module named 'folder_paths'
[ComfyUI] [sd-webui-comfyui] Stopped callback listeners for process comfyui
GumGum10 commented 1 year ago

Same error *** Error loading script: comfyui.py Traceback (most recent call last): File "C:\Apps\Stable Diffusion 160 September\modules\scripts.py", line 319, in load_scripts script_module = script_loading.load_module(scriptfile.path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Apps\Stable Diffusion 160 September\modules\script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "C:\Apps\Stable Diffusion 160 September\extensions\ComfyUI\scripts\comfyui.py", line 4, in from lib_comfyui import global_state, platform_utils, external_code, default_workflow_types, comfyui_process File "C:\Apps\Stable Diffusion 160 September\extensions\ComfyUI\lib_comfyui\comfyui_process.py", line 10, in from lib_comfyui.comfyui import pre_main File "C:\Apps\Stable Diffusion 160 September\extensions\ComfyUI\lib_comfyui\comfyui\pre_main.py", line 29, in from lib_comfyui.webui import paths, settings File "C:\Apps\Stable Diffusion 160 September\extensions\ComfyUI\lib_comfyui\webui\paths.py", line 5, in import folder_paths ModuleNotFoundError: No module named 'folder_paths'

Tested in 1.5.1, 1.5.2, 1.6.0.

ljleb commented 1 year ago

The problem is that the comfyui directory is empty. git pull manually at the expected location should be a workaround for now. I'm not sure why the git install script does not work for so many people.

GumGum10 commented 1 year ago

Hi @ljleb! Sorry for not saying this earlier but thank you so much for working on this and for your help here! Switching back to a1111's 1.6.0 and manually running install_comfyui.py from sd-webui-comfyui has fixed all issues for me. Thanks again!

ljleb commented 1 year ago

Switching back to a1111's 1.6.0 and manually running install_comfyui.py from sd-webui-comfyui has fixed all issues for me.

Nice. Do you know why the script was not executed when you clicked on the install button? Was there no install screen in the Comfyui tab the first time you activated the extension?

GumGum10 commented 11 months ago

Switching back to a1111's 1.6.0 and manually running install_comfyui.py from sd-webui-comfyui has fixed all issues for me.

Nice. Do you know why the script was not executed when you clicked on the install button? Was there no install screen in the Comfyui tab the first time you activated the extension?

Sorry for the late response! The install went through without any errors but it seems like the folder was just not being created.