Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct package install conflicts with vanilla ComfyUI #30

Open
ryanontheinside opened this issue Feb 6, 2025 · 6 comments
Open

Direct package install conflicts with vanilla ComfyUI #30

ryanontheinside opened this issue Feb 6, 2025 · 6 comments

Comments

@ryanontheinside
Copy link

ryanontheinside commented Feb 6, 2025

Expected Behavior

The ComfyUI fork should work as a Python package dependency alongside a vanilla ComfyUI installation, whether installed directly via pip+git or from a local clone.

Actual behavior

  • Working: Installing from local clone works alongside vanilla ComfyUI:

    git clone https://github.com/hiddenswitch/ComfyUI.git hiddenswitch
    cd hiddenswitch
    git checkout ce3583ad42c024b8f060d0002cbe20c265da6dc8
    pip install .

    Result: Both vanilla ComfyUI and the package version function correctly along side one another.

  • Breaking: Direct package installation breaks vanilla ComfyUI:

    pip install git+https://github.com/hiddenswitch/ComfyUI.git@ce3583ad42c024b8f060d0002cbe20c265da6dc8

    Result: After this installation, the vanilla ComfyUI installation stops working. Specifically:

    • The vanilla ComfyUI UI/workspace no longer functions
    • See included debug logs

Steps to Reproduce

  1. Set up vanilla ComfyUI installation
  2. Try direct installation method:
    pip install git+https://github.com/hiddenswitch/ComfyUI.git@ce3583ad42c024b8f060d0002cbe20c265da6dc8
  3. Observe that it fails to work properly
  4. Uninstall and try local installation method:
    git clone https://github.com/hiddenswitch/ComfyUI.git
    cd ComfyUI
    git checkout ce3583ad42c024b8f060d0002cbe20c265da6dc8
    pip install .
  5. Observe that it works correctly

Debug Logs

Some select errors during vanilla ComfyUI startup:


Traceback (most recent call last):
  File "C:\Users\Ryan\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\main.py", line 295, in <module>
    event_loop, _, start_all_func = start_comfyui()
                                    ^^^^^^^^^^^^^^^
  File "C:\Users\Ryan\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\main.py", line 266, in start_comfyui
    hijack_progress(prompt_server)
  File "C:\Users\Ryan\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\main.py", line 228, in hijack_progress
    comfy.utils.set_progress_bar_global_hook(hook)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'comfy.utils' has no attribute 'set_progress_bar_global_hook'. Did you mean: 'set_progress_bar_enabled'?



Traceback (most recent call last):
  File "C:\Users\Ryan\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\nodes.py", line 2106, 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 "D:\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\comfy_extras\nodes_latent.py", line 2, in <module>
    import comfy_extras.nodes_post_processing
ModuleNotFoundError: No module named 'comfy_extras.nodes_post_processing'

Cannot import D:\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\comfy_extras\nodes_latent.py module for custom nodes: No module named 'comfy_extras.nodes_post_processing'
Successfully imported spandrel_extra_arches: support for non commercial upscale models.
Traceback (most recent call last):
  File "C:\Users\Ryan\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\nodes.py", line 2106, 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 "D:\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\comfy_extras\nodes_video_model.py", line 6, in <module>
    import comfy_extras.nodes_model_merging
ModuleNotFoundError: No module named 'comfy_extras.nodes_model_merging'

Cannot import D:\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\comfy_extras\nodes_video_model.py module for custom nodes: No module named 'comfy_extras.nodes_model_merging'
Traceback (most recent call last):
  File "C:\Users\Ryan\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\nodes.py", line 2106, 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 "D:\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\comfy_extras\nodes_model_merging_model_specific.py", line 1, in <module>
    import comfy_extras.nodes_model_merging
ModuleNotFoundError: No module named 'comfy_extras.nodes_model_merging'

Cannot import D:\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\comfy_extras\nodes_model_merging_model_specific.py module for custom nodes: No module named 'comfy_extras.nodes_model_merging'
Traceback (most recent call last):
  File "C:\Users\Ryan\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\nodes.py", line 2106, 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 "D:\Cursor Projects\ryanontheinside_github\Comfy_Fresh\ComfyUI\comfy_extras\nodes_sd3.py", line 6, in <module>
    import comfy_extras.nodes_slg
ModuleNotFoundError: No module named 'comfy_extras.nodes_slg'

Other

This fork is fantastic - it enables so many possibilities. I'm sharing this behavior because I'm genuinely unsure if it's:

  1. An actual issue in the package setup
  2. Expected Python packaging behavior I'm not familiar with
  3. Something that needs a different approach altogether

Any insights would be greatly appreciated! Happy to provide more details if needed.

@Chaoses-Ib
Copy link

This issue has existed for a long time, I (and @exdysa) have encountered it half a year ago: comfyanonymous#3702

I thought it's probably unfixable since they both use the same package name (e.g. comfy.utils) and just added it to the troubleshooting of ComfyScript. But if a local installation can work around it then maybe there is some Python path priority magic can fix it with direct installation.

@doctorpangloss
Copy link
Member

doctorpangloss commented Feb 7, 2025

I can reproduce the issue by installing locally too. I'm not sure why in your case the from-local versus remote-git installation changes the behavior.

The underlying issue is that upstream is using relative imports sometimes, but it lacks __init__.py in the right places for that to work. It generally works because things hack the sys.path anyway and paper over this mistake.

The most robust workaround is to add the missing __init__.py files yourself in upstream:

find comfy/ comfy_extras/ -type d -exec touch {}/__init__.py \;
Get-ChildItem -Path comfy/,comfy_extras/ -Directory -Recurse | ForEach-Object { if (-not (Test-Path (Join-Path $_.FullName "__init__.py"))) { New-Item -Path (Join-Path $_.FullName "__init__.py") -ItemType File } }

If you run this in the ComfyUI directory, the problem should go away. If it does I can research an approach that doesn't require adding these files and otherwise behaves the same way.

@ryanontheinside
Copy link
Author

@doctorpangloss installing locally in editable mode behaves differently

@doctorpangloss
Copy link
Member

@doctorpangloss installing locally in editable mode behaves differently

I believe you I just can't figure out why lol

@ryanontheinside
Copy link
Author

ryanontheinside commented Feb 9, 2025 via email

@doctorpangloss
Copy link
Member

doctorpangloss commented Feb 10, 2025

regarding editable mode specifically the .pth files interact in a way where they are loaded after the directory-search style imports when using comfyui upstream, whereas when installed as a package... hard to say

in the meantime I strongly recommend the workaround. I can probably convince upstream to add the __init__.py files anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants