ImportError: cannot import name ‘_append_guide_attention_entry’ from ‘comfy_extras.nodes_lt’ (C:\Ai\ComfyUI_Portable\ComfyUI\comfy_extras\nodes_lt.py)

用户在使用 ComfyUI 以及 ComfyUI-KJNodes 自定义节点时,ComfyUI Manager 显示 "Import Failed" 错误。报错在导入 comfyui-kjnodes 模块的过程中触发,涉及 ltxv_nodes.py 尝试从 comfy_extras.nodes_l

ImportError: cannot import name '_append_guide_attention_entry' from 'comfy_extras.nodes_lt' (C:\Ai\ComfyUI_Portable\ComfyUI\comfy_extras\nodes_lt.py)

ImportError: cannot import name ‘_append_guide_attention_entry’ from ‘comfy_extras.nodes_lt’ (C:\Ai\ComfyUI_Portable\ComfyUI\comfy_extras\nodes_lt.py)

快速结论:此报错通常出现在 ComfyUI 及其自定义节点版本不匹配时,优先确认 ComfyUI 是否为最新 nightly 版本,并尝试重新运行更新脚本。

问题场景

用户在使用 ComfyUI 以及 ComfyUI-KJNodes 自定义节点时,ComfyUI Manager 显示 “Import Failed” 错误。报错在导入 comfyui-kjnodes 模块的过程中触发,涉及 ltxv_nodes.py 尝试从 comfy_extras.nodes_lt 导入 _append_guide_attention_entry 失败。

报错原文

Error message occurred while importing the 'ComfyUI-KJNodes' module.

Traceback (most recent call last):
  File "C:\Ai\ComfyUI_Portable\ComfyUI\nodes.py", line 2156, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 1027, in exec_module
  File "<frozen importlib._bootstrap>", line 555, in _call_with_frames_removed
  File "C:\Ai\ComfyUI_Portable\ComfyUI\custom_nodes\comfyui-kjnodes\__init__.py", line 83, in <module>
    from .nodes.preview_override_node import ModelPreviewOverrideKJ, GetPreviewOverrideFramesKJ
  File "C:\Ai\ComfyUI_Portable\ComfyUI\custom_nodes\comfyui-kjnodes\nodes\preview_override_node.py", line 18, in <module>
    from .ltxv_nodes import WrappedPreviewer as _LTXWrappedPreviewer, get_ltx_rgb_factors as _ltx_rgb_factors
  File "C:\Ai\ComfyUI_Portable\ComfyUI\custom_nodes\comfyui-kjnodes\nodes\ltxv_nodes.py", line 1, in <module>
    from comfy_extras.nodes_lt import get_noise_mask, LTXVAddGuide, _append_guide_attention_entry
ImportError: cannot import name '_append_guide_attention_entry' from 'comfy_extras.nodes_lt' (C:\Ai\ComfyUI_Portable\ComfyUI\comfy_extras\nodes_lt.py)

原因分析

可能原因:ComfyUI 版本过旧,具体表现为 comfy_extras.nodes_lt 模块中缺少 _append_guide_attention_entry 这一函数。该函数在当前 nightly 版本的 ComfyUI 中确实存在,用户更新 ComfyUI 时可能因更新脚本未正确执行而导致版本未更新至最新。

环境排查

  • 确认 ComfyUI 是否为最新的 nightly 版本(而非 stable 版本)。
  • 检查 ComfyUI-KJNodes 版本是否与 ComfyUI 版本兼容。
  • 确认 ComfyUI 的更新脚本(如 update_comfyui.bat)是否已成功运行。
  • 核实 comfy_extras/nodes_lt.py 文件内是否包含 _append_guide_attention_entry 定义。

解决步骤

  1. 打开 ComfyUI 安装目录(例如 C:\Ai\ComfyUI_Portable\ComfyUI),找到更新脚本(通常为 update_comfyui.bat)。
  2. 重新运行该更新脚本,确保网络连接正常,等待更新完成。
  3. 如果更新脚本运行失败,可以尝试手动通过 Git 拉取最新代码,或重新下载 ComfyUI 完整包。
  4. 完成更新后,重启 ComfyUI 并检查是否仍显示导入错误。
  5. 如果问题依旧,检查 comfy_extras/nodes_lt.py 是否存在,并确认文件中包含 _append_guide_attention_entry 的定义。若缺失,则说明更新未成功,需重新执行更新。

可优先尝试:在 Issue 讨论中,用户通过重新运行 update_comfyui.bat 脚本解决了问题。

验证方法

重新启动 ComfyUI,查看 ComfyUI Manager 界面中 “Import Failed” 提示是否消失。如果能够正常加载 KJNodes 节点且无 Traceback 报错,则问题已解决。

参考来源

kijai/ComfyUI-KJNodes #649

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 7739

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注