Fix LoadVideosFromFolder VHS import in Windows

VideoHelperSuite import fails on Windows even when VHS is properly
installed, due to custom node module names being stored as full file
paths for some reason.
Add fallback to sys.modules search when standard imports fail.
This commit is contained in:
stuttlepress 2025-09-23 03:39:49 -05:00
parent e81f33508b
commit 11a482d3c3

View File

@ -3751,7 +3751,29 @@ class LoadVideosFromFolder:
try:
cls.vhs_nodes = importlib.import_module("comfyui-videohelpersuite.videohelpersuite")
except ImportError:
raise ImportError("This node requires ComfyUI-VideoHelperSuite to be installed.")
# Fallback to sys.modules search for Windows compatibility
import sys
vhs_module = None
for module_name in sys.modules:
if 'videohelpersuite' in module_name and 'videohelpersuite' in sys.modules[module_name].__dict__:
vhs_module = sys.modules[module_name]
break
if vhs_module is None:
# Try direct access to the videohelpersuite submodule
for module_name in sys.modules:
if module_name.endswith('videohelpersuite'):
vhs_module = sys.modules[module_name]
break
if vhs_module is not None:
cls.vhs_nodes = vhs_module
else:
raise ImportError("This node requires ComfyUI-VideoHelperSuite to be installed.")
except ImportError:
raise ImportError("This node requires ComfyUI-VideoHelperSuite to be installed.")
@classmethod
def INPUT_TYPES(s):
return {