TypeError: str expected

用户在 Windows 系统下运行 ComfyUI 便携版(ComfyUI_windows_portable),使用 DWpreprocessor 或 LineArt 等预处理节点时触发。更新 comfyui_controlnet_aux 节点后,ComfyUI 启动时显示 “(IMPORT FAI

TypeError: str expected

TypeError: str expected

快速结论:这个报错通常出现在 ComfyUI 更新 comfyui_controlnet_aux 自定义节点后,导入节点模块失败导致所有预处理节点都无法加载。优先检查节点版本是否与 ComfyUI 兼容,并尝试回退到较旧提交。

问题场景

用户在 Windows 系统下运行 ComfyUI 便携版(ComfyUI_windows_portable),使用 DWpreprocessor 或 LineArt 等预处理节点时触发。更新 comfyui_controlnet_aux 节点后,ComfyUI 启动时显示 “(IMPORT FAILED)” 错误,导致节点无法加载。

报错原文

0.0 seconds (IMPORT FAILED): C:\Users\Big Bane\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux

Cannot import C:\AI\ComfyUI\ComfyUI\custom_nodes\comfyui_controlnet_aux module for custom nodes: str expected, not int

原因分析

可能原因:comfyui_controlnet_aux 自定义节点的最近更新中,代码某个地方期望接收字符串(str)类型的参数,但实际上传入了整数(int),导致导入阶段抛出 TypeError: str expected, not int。这个类型错误造成整个节点模块无法加载,从而使所有预处理节点(如 DWpreprocessor、LineArt 等)失效。

环境排查

  • 确认 ComfyUI 版本(便携版或手动安装版)
  • 确认 comfyui_controlnet_aux 节点是否已是最新
  • 确认 Python 环境:报错中显示使用 python_embeded 解释器
  • 确认 torch 版本:示例中为 2.0.1+cu118

解决步骤

  1. 回退到较旧的提交版本:进入 comfyui_controlnet_aux 节点目录(例如 C:\ComfyUI\custom_nodes\comfyui_controlnet_aux),使用 git 将仓库回退到更新前的提交。用户通过此方法“暂时使其工作”。
  2. 等待仓库作者修复:该 Issue 在 2023-10-16 被标记为已修复(Fixed),更新到最新提交即可解决。
  3. 如果仍在出现:删除节点目录后重新克隆仓库,或通过 ComfyUI-Manager 重新安装节点。

验证方法

重启 ComfyUI,检查启动日志中是否仍有 “IMPORT FAILED” 或 “TypeError: str expected” 错误。打开工作流,拖入原本失败的预处理节点(如 DWpreprocessor),确认节点正常加载且能生成预览。

参考来源

Fannovel16/comfyui_controlnet_aux #76

GamsGo AI

AI 工具推荐

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

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

了解 GamsGo AI

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

celebrityanime
celebrityanime
文章: 11433

发表回复

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