You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ComfyUI安装ControlNet Auxiliary报错:无法导入resize_image_with_pad

解决ComfyUI中ControlNet Auxiliary的ImportError问题

问题背景

在Windows系统下通过ComfyUI Manager安装ControlNet Auxiliary后,出现以下ImportError:

cannot import name 'resize_image_with_pad' from 'controlnet_aux.util'

加载图片传入Canny Edge节点时也触发相同错误。已尝试更新ComfyUI、更新所有组件、重启程序、重新安装Auxiliary、手动安装requirements.txt依赖,均未解决。

报错日志详情

[comfyui_controlnet_aux] | INFO -> Some nodes failed to load:
        Failed to import module dwpose because ImportError: cannot import name 'resize_image_with_pad' from 'controlnet_aux.util' (C:\Users\user\Downloads\ComfyUI_windows_portable\python_embeded\Lib\site-packages\controlnet_aux\util.py)

Check that you properly installed the dependencies.
If you think this is a bug, please report it on the github page (https://github.com/Fannovel16/comfyui_controlnet_aux/issues)

Import times for custom nodes:
   0.0 seconds: C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\websocket_image_save.py
   0.0 seconds: C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet
   0.3 seconds (IMPORT FAILED): C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-ControlnetAux
   0.4 seconds: C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Manager
   0.6 seconds: C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux

Starting server

To see the GUI go to: http://127.0.0.1:8188
FETCH DATA from: C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Manager\extension-node-map.json [DONE]
got prompt
!!! Exception during processing!!! cannot import name 'resize_image_with_pad' from 'controlnet_aux.util' (C:\Users\user\Downloads\ComfyUI_windows_portable\python_embeded\Lib\site-packages\controlnet_aux\util.py)
Traceback (most recent call last):
  File "C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\node_wrappers\canny.py", line 18, in execute
    from controlnet_aux.canny import CannyDetector
  File "C:\Users\user\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux\src\controlnet_aux\canny\__init__.py", line 5, in <module>
    from controlnet_aux.util import resize_image_with_pad, common_input_validate, HWC3
ImportError: cannot import name 'resize_image_with_pad' from 'controlnet_aux.util' (C:\Users\user\Downloads\ComfyUI_windows_portable\python_embeded\Lib\site-packages\controlnet_aux\util.py)

可行解决方案

  • 修复版本冲突:报错显示全局Python环境的controlnet_aux包缺少目标函数,与自定义节点依赖的版本不匹配。操作步骤:
    1. 打开ComfyUI便携版的终端,运行命令:python_embeded\python.exe -m pip uninstall controlnet_aux
    2. 进入ComfyUI\custom_nodes\comfyui_controlnet_aux目录,运行:python_embeded\python.exe -m pip install -e .,强制环境使用自定义节点内的模块版本
  • 删除全局冗余包:直接删除C:\Users\user\Downloads\ComfyUI_windows_portable\python_embeded\Lib\site-packages下的controlnet_aux文件夹及对应的.dist-info文件夹,避免全局包干扰
  • 清理缓存:删除ComfyUI目录及所有自定义节点内的__pycache__文件夹,重启程序
  • 卸载重复节点:日志显示同时存在ComfyUI-ControlnetAux和comfyui_controlnet_aux两个同名节点,通过ComfyUI Manager卸载其中一个,消除冲突

内容的提问来源于stack exchange,提问作者KT9000

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 08:59:58