当前位置: 首页 > news >正文

【技术分享】ComfyUI中protobuf版本兼容性问题的优雅解决方案:猴子补丁实战

【技术分享】ComfyUI中protobuf版本兼容性问题的优雅解决方案:猴子补丁实战




引言

在AI艺术创作领域,ComfyUI凭借其强大的节点式工作流和丰富的插件生态系统,已经成为了许多创作者的首选工具。然而,随着依赖库版本的不断更新,兼容性问题也随之而来。本文将详细记录一次解决ComfyUI中protobuf版本兼容性问题的完整过程,希望能为遇到类似问题的开发者和创作者提供参考。




问题描述

在使用ComfyUI进行创作时,安装了AlekPet节点插件后,系统在启动过程中出现了以下错误:

在这里插入图片描述

### [END] ComfyUI AlekPet Nodes ###
AttributeError: 'MessageFactory' object has no attribute 'GetPrototype'

这个错误可能导致AlekPet节点无法正常加载运行,会影响相关功能的使用。




错误示例

完整的错误日志片段如下:

Microsoft Windows [Version 10.0.28000.1]
(c) Microsoft Corporation. All rights reserved.(Win_ComfyUI) H:\PythonProjects1\Win_ComfyUI>python main.py
Adding extra search path checkpoints G:\PythonProjects2\stable-diffusion-webui\models\Stable-diffusion
...
### [START] ComfyUI AlekPet Nodes ###
...
### [END] ComfyUI AlekPet Nodes ###
AttributeError: 'MessageFactory' object has no attribute 'GetPrototype'



环境信息

  • 操作系统:Windows 11
  • ComfyUI版本:0.3.64 (开源代码部署版)
  • Python版本:3.12.11
  • protobuf版本:6.33.0
  • AlekPet节点版本:v1.0.88

ComfyUI 开源地址

protobuf版本及相关信息


节点的开源地址: ComfyUI_Custom_Nodes_AlekPet

在这里插入图片描述




原因分析

初步分析

从错误信息来看,这是一个典型的属性错误,表明MessageFactory对象存在,但它没有GetPrototype方法。这通常意味着:

  1. 代码中调用了某个对象的方法,但该方法在当前版本中不存在
  2. 可能是由于库版本升级导致的API变更


深入调查

通过查阅相关资料和分析,我们发现了问题的根源:

protobuf 发行文档

  1. protobuf版本变更:在protobuf 4.x版本以后,MessageFactory类的GetPrototype方法被废弃,并在6.x版本中完全移除
  2. 替代方法:官方推荐使用GetMessageClass方法替代
  3. 兼容性问题:AlekPet节点插件仍然在使用旧的GetPrototype方法,而当前环境使用的是protobuf 6.33.0版本


为什么不选择降级protobuf?

考虑到 ComfyUI 虚拟环境中已经安装了数百个依赖包,包括mediapipe、tensorflow、onnx等重要的AI库,降级protobuf可能会导致其他依赖包出现问题。因此,我们需要寻找一个不需要改变protobuf版本的解决方案。




解决方案:猴子补丁(Monkey Patching)

经过研究,我们决定采用猴子补丁的方式来解决这个兼容性问题。猴子补丁是一种在运行时动态修改代码的技术,可以为类动态添加缺失的方法。

参考来自日本网友的解决方案:如何在 TensorFlow 中将 GetPrototype 改为 GetMessageClass

参考来自 GitHub 网友的讨论:使用提供的微调脚本微调模型时出现问题

pypi :protobuf
protobuf 版本文档



解决方案原理

我们的解决方案基于以下原理:

  1. 在程序运行时检测MessageFactory类是否缺少GetPrototype方法
  2. 如果缺少,则动态添加该方法
  3. 新添加的GetPrototype方法内部调用新版本的GetMessageClass方法
  4. 这样,旧代码调用GetPrototype时,实际上会执行GetMessageClass,从而解决兼容性问题


具体实现

步骤一:创建补丁文件

在ComfyUI根目录创建protobuf_patch.py文件:

"""
Protobuf兼容性补丁
解决GetPrototype缺失问题
基于: https://note.com/198619891990/n/na832c57019a2
"""def apply_protobuf_patch():try:from google.protobuf.message_factory import MessageFactory# 检查是否已经有GetPrototype方法if hasattr(MessageFactory, 'GetPrototype'):print("ℹ️  Protobuf已经有GetPrototype方法,无需补丁")return True# 定义替代方法def get_prototype_replacement(self, descriptor):"""GetPrototype方法的替代实现调用新版本的GetMessageClass方法"""try:return self.GetMessageClass(descriptor)except Exception as e:print(f"⚠️  GetPrototype替代方法执行失败: {e}")# 如果失败,返回一个默认的空消息类from google.protobuf.message import Messageclass DefaultMessage(Message):def __init__(self, *args, **kwargs):super().__init__(*args, **kwargs)def ParseFromString(self, s):passdef SerializeToString(self):return b""return DefaultMessage# 应用补丁MessageFactory.GetPrototype = get_prototype_replacementprint("✅ Protobuf兼容性补丁已成功应用")return Trueexcept Exception as e:print(f"❌ Protobuf补丁应用失败: {e}")import tracebacktraceback.print_exc()return False# 自动应用补丁
if __name__ == "__main__":apply_protobuf_patch()

在 ComfyUI 根目录创建protobuf_patch.py文件


步骤二:在AlekPet节点中加载补丁

修改H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_Custom_Nodes_AlekPet\__init__.py文件,在文件开头添加以下代码:

# Title: ComfyUI Install Customs Nodes and javascript files
# Author: AlekPet
# Version: 2025.06.26# ====================== 添加protobuf补丁代码 ======================
try:# 导入sys模块以添加ComfyUI根目录到路径import sys# 添加ComfyUI根目录到Python路径,以便找到protobuf_patch.pysys.path.append("H:/PythonProjects1/Win_ComfyUI")# 导入并应用protobuf补丁from protobuf_patch import apply_protobuf_patchapply_protobuf_patch()except Exception as e:print(f"⚠️  [AlekPet节点] 加载protobuf补丁失败: {e}")import tracebacktraceback.print_exc()
# ==================================================================# 原有的代码...

在 AlekPet 节点中加载补丁



替代方案:内置补丁

如果外部文件加载失败,也可以直接在AlekPet节点的__init__.py中定义补丁函数:

# Title: ComfyUI Install Customs Nodes and javascript files
# Author: AlekPet
# Version: 2025.06.26# ====================== 直接定义protobuf补丁 ======================
try:from google.protobuf.message_factory import MessageFactory# 检查是否已经有GetPrototype方法if not hasattr(MessageFactory, 'GetPrototype'):print("⚠️  [AlekPet节点] 检测到protobuf版本不兼容,应用内置补丁...")# 定义替代方法def get_prototype_replacement(self, descriptor):try:return self.GetMessageClass(descriptor)except Exception as e:print(f"⚠️  GetPrototype替代方法执行失败: {e}")from google.protobuf.message import Messageclass DefaultMessage(Message):def __init__(self, *args, **kwargs):super().__init__(*args, **kwargs)def ParseFromString(self, s):passdef SerializeToString(self):return b""return DefaultMessage# 应用补丁MessageFactory.GetPrototype = get_prototype_replacementprint("✅ [AlekPet节点] Protobuf兼容性补丁已成功应用")else:print("ℹ️  [AlekPet节点] Protobuf版本兼容,无需补丁")except Exception as e:print(f"❌ [AlekPet节点] 内置protobuf补丁应用失败: {e}")import tracebacktraceback.print_exc()
# ==================================================================# 原有的代码...



实施效果验证

修复后的启动日志

应用补丁后,ComfyUI启动日志显示:

✅ Protobuf兼容性补丁已成功应用
...
### [START] ComfyUI AlekPet Nodes v1.0.88 ###
Node -> ArgosTranslateNode: ArgosTranslateCLIPTextEncodeNode, ArgosTranslateTextNode [Loading]
Node -> ChatGLMNode: ChatGLM4TranslateCLIPTextEncodeNode, ChatGLM4TranslateTextNode, ChatGLM4InstructNode, ChatGLM4InstructMediaNode [Loading]
Node -> DeepLXTranslateNode:  [Loading]
Node -> DeepTranslatorNode: DeepTranslatorCLIPTextEncodeNode, DeepTranslatorTextNode [Loading]
Node -> ExtrasNode: PreviewTextNode, HexToHueNode, ColorsCorrectNode [Loading]
Node -> GoogleTranslateNode: GoogleTranslateCLIPTextEncodeNode, GoogleTranslateTextNode [Loading]
Node -> IDENode: IDENode [Loading]
Node -> PainterNode: PainterNode [Loading]
Node -> PoseNode: PoseNode [Loading]
### [END] ComfyUI AlekPet Nodes ###
...
Starting server
To see the GUI go to: http://127.0.0.1:8188

修复后的启动日志

附完整启动日志以供参考

Microsoft Windows [Version 10.0.28000.1]
(c) Microsoft Corporation. All rights reserved.(Win_ComfyUI) H:\PythonProjects1\Win_ComfyUI>python main.py
Adding extra search path checkpoints G:\PythonProjects2\stable-diffusion-webui\models\Stable-diffusion
Adding extra search path configs G:\PythonProjects2\stable-diffusion-webui\models\Stable-diffusion
Adding extra search path vae G:\PythonProjects2\stable-diffusion-webui\models\VAE
Adding extra search path loras G:\PythonProjects2\stable-diffusion-webui\models\Lora
Adding extra search path loras G:\PythonProjects2\stable-diffusion-webui\models\LyCORIS
Adding extra search path upscale_models G:\PythonProjects2\stable-diffusion-webui\models\ESRGAN
Adding extra search path upscale_models G:\PythonProjects2\stable-diffusion-webui\models\RealESRGAN
Adding extra search path upscale_models G:\PythonProjects2\stable-diffusion-webui\models\SwinIR
Adding extra search path embeddings G:\PythonProjects2\stable-diffusion-webui\embeddings
Adding extra search path hypernetworks G:\PythonProjects2\stable-diffusion-webui\models\hypernetworks
Adding extra search path controlnet G:\PythonProjects2\stable-diffusion-webui\models\ControlNet
[START] Security scan
[DONE] Security scan
## ComfyUI-Manager: installing dependencies done.
** ComfyUI startup time: 2025-11-10 23:05:10.332
** Platform: Windows
** Python version: 3.12.11 (main, Aug 18 2025, 19:17:54) [MSC v.1944 64 bit (AMD64)]
** Python executable: H:\PythonProjects1\Win_ComfyUI\.venv\Scripts\python.exe
** ComfyUI Path: H:\PythonProjects1\Win_ComfyUI
** ComfyUI Base Folder Path: H:\PythonProjects1\Win_ComfyUI
** User directory: H:\PythonProjects1\Win_ComfyUI\user
** ComfyUI-Manager config path: H:\PythonProjects1\Win_ComfyUI\user\default\ComfyUI-Manager\config.ini
** Log path: H:\PythonProjects1\Win_ComfyUI\user\comfyui.logPrestartup times for custom nodes:0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-easy-use0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\rgthree-comfy4.2 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-ManagerCheckpoint files will always be loaded safely.
Total VRAM 24576 MB, total RAM 97560 MB
pytorch version: 2.7.1+cu126
xformers version: 0.0.31.post1
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3090 : cudaMallocAsync
Using xformers attention
Python version: 3.12.11 (main, Aug 18 2025, 19:17:54) [MSC v.1944 64 bit (AMD64)]
ComfyUI version: 0.3.64
ComfyUI frontend version: 1.27.10
[Prompt Server] web root: H:\PythonProjects1\Win_ComfyUI\.venv\Lib\site-packages\comfyui_frontend_package\static
Note: NumExpr detected 24 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16.
NumExpr defaulting to 16 threads.
2025-11-10 23:05:18.887288: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
[H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfy-mtb] | INFO -> loaded 108 nodes successfuly
Web extensions folder found at H:\PythonProjects1\Win_ComfyUI\web\extensions\ComfyLiterals
Imported AddPaddingAdvanced successfully
Imported AddPaddingBase successfully
Imported AD_ImageResize successfully
Imported AD_MockupMaker successfully
Imported AD_PosterMaker successfully
Imported AD_PromptSaver successfully
Imported ComfyUI-FofrToolkit successfully
Imported ComfyUI-ImageCaptioner successfully
Imported ComfyUI-imageResize successfully
Imported ComfyUI-textAppend successfully
Imported imagecreatemask successfully
Imported multiline_string successfully
Imported AddPaddingAdvanced successfully
Imported AddPaddingBase successfully
Imported AD_ImageResize successfully
Imported AD_MockupMaker successfully
Imported AD_PosterMaker successfully
Imported AD_PromptSaver successfully
Imported ComfyUI-FofrToolkit successfully
Imported ComfyUI-ImageCaptioner successfully
Imported ComfyUI-imageResize successfully
Imported ComfyUI-textAppend successfully
Imported imagecreatemask successfully
Imported multiline_string successfully
[Allor]: 0 nodes were overridden.
[Allor]: 12 modules were enabled.
[Allor]: 98 nodes were loaded.
[AnimateDiff] - WARNING - xformers is enabled but it has a bug that can cause issue while using with AnimateDiff.
Adding H:\PythonProjects1\Win_ComfyUI\custom_nodes to sys.path
Efficiency Nodes: Attempting to add Control Net options to the 'HiRes-Fix Script' Node (comfyui_controlnet_aux add-on)...Success!
Loaded Efficiency nodes from H:\PythonProjects1\Win_ComfyUI\custom_nodes\efficiency-nodes-comfyui
Loaded ControlNetPreprocessors nodes from H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_controlnet_aux
Loaded AdvancedControlNet nodes from H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet
Loaded AnimateDiff from H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-animatediff\animatediff/sliding_schedule.py
Loaded IPAdapter nodes from H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_IPAdapter_plus
Loaded VideoHelperSuite from H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-VideoHelperSuite
### Loading: ComfyUI-Impact-Pack (V8.25.1)
### Loading: ComfyUI-Impact-Pack (V8.25.1)
Loaded ImpactPack nodes from H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Impact-Pack
[Impact Pack] Wildcards loading done.
[Impact Pack] Wildcards loading done.
[ComfyUI-Easy-Use] server: v1.3.4 Loaded
[ComfyUI-Easy-Use] web root: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-easy-use\web_version/v2 Loaded
ExcelPicker Node Loaded Successfully
[Flow Control] Checkpoint presets database : H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Flow-Control\db/checkpoints.json
ComfyUI-GGUF: Partial torch compile only, consider updating pytorch
[Flow Control] Flux presets database : H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Flow-Control\db/flux_checkpoints.json
[Flow Control] Lora info database : H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Flow-Control\db/loras.json
------------------------------------------
Flow Control v1.00 :  15 Nodes Loaded
------------------------------------------
[Flow Control] API server started...
ComfyUI-GGUF: Partial torch compile only, consider updating pytorch
✅ Holaf Custom Nodes initialized
Total VRAM 24576 MB, total RAM 97560 MB
pytorch version: 2.7.1+cu126
xformers version: 0.0.31.post1
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3090 : cudaMallocAsync
### Loading: ComfyUI-Impact-Pack (V8.25.1)
[Impact Pack] Wildcards loading done.
[inference_core_nodes.controlnet_preprocessors] | INFO -> Using ckpts path: H:\PythonProjects1\Win_ComfyUI\.venv\src\inference-core-nodes\src\inference_core_nodes\controlnet_preprocessors\ckpts
[inference_core_nodes.controlnet_preprocessors] | INFO -> Using symlinks: False
[inference_core_nodes.controlnet_preprocessors] | INFO -> Using ort providers: ['CUDAExecutionProvider', 'DirectMLExecutionProvider', 'OpenVINOExecutionProvider', 'ROCMExecutionProvider', 'CPUExecutionProvider', 'CoreMLExecutionProvider']
### Loading: ComfyUI-Inspire-Pack (V1.22.2)
### Loading: ComfyUI-Manager (V3.37)
[ComfyUI-Manager] network_mode: public
### ComfyUI Revision: 1 [524c4af2] | Released on '2025-10-24'
--------------### Mixlab Nodes: Loaded
ChatGPT.available False
edit_mask.available True
ClipInterrogator.available True
PromptGenerate.available True
ChinesePrompt.available True
RembgNode_.available True
TripoSR.available
MiniCPMNode.available
Scenedetect.available
FishSpeech.available
SenseVoice.available False
Whisper.available False
fal-client## OK
FalVideo.available-------------- 
======================================== ComfyUI-nunchaku Initialization ========================================
Nunchaku version: 1.0.0
ComfyUI-nunchaku version: 1.0.1
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json
=================================================================================================================
================================================================================================================================
ComfyUI-NunchakuFluxLoraStacker: Loading Nunchaku FLUX LoRA Stacker nodes...
ComfyUI-NunchakuFluxLoraStacker: Loaded 1 nodes
ComfyUI-NunchakuFluxLoraStacker: JavaScript directory: js
================================================================================================================================[ReActor] - STATUS - Running v0.6.2-a4 in ComfyUI
Torch version: 2.7.1+cu126
H:\PythonProjects1\Win_ComfyUI
############################################
H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Universal-Styler\CSV
############################################
['H:\\PythonProjects1\\Win_ComfyUI\\custom_nodes\\ComfyUI-Universal-Styler\\CSV\\naifilters.csv', 'H:\\PythonProjects1\\Win_ComfyUI\\custom_nodes\\ComfyUI-Universal-Styler\\CSV\\naistyles.csv', 'H:\\PythonProjects1\\Win_ComfyUI\\custom_nodes\\ComfyUI-Universal-Styler\\CSV\\naitypes.csv']
############################################
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/github-stats.json
Initializing ComfyUI-VideoUpscale_WithModel__     ______   ____                      ____              ____ _      _ 
\ \   / /  _ \ / ___| __ _ _ __ ___   ___|  _ \  _____   __/ ___(_)_ __| |\ \ / /| |_) | |  _ / _` | '_ ` _ \ / _ \ | | |/ _ \ \ / / |  _| | '__| |\ V / |  _ <| |_| | (_| | | | | | |  __/ |_| |  __/\ V /| |_| | | |  | |\_/  |_| \_\\____|\__,_|_| |_| |_|\___|____/ \___| \_/  \____|_|_|  |_|🎮 VRGameDevGirl custom nodes loaded successfully! 🎞️(pysssss:WD14Tagger) [DEBUG] Available ORT providers: TensorrtExecutionProvider, CUDAExecutionProvider, CPUExecutionProvider
(pysssss:WD14Tagger) [DEBUG] Using ORT providers: CUDAExecutionProvider, CPUExecutionProvider
Workspace manager - Openning file hash dict
### Loading: Workspace Manager (V1.0.0)
assets_dir:H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_checkpointloader_ext\web/assets
------------------------------------------
Comfyroll Studio v1.76 :  175 Nodes Loaded
------------------------------------------
** For changes, please see patch notes at https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/blob/main/Patch_Notes.md
** For help, please see the wiki at https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki
------------------------------------------
[H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_controlnet_aux] | INFO -> Using ckpts path: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_controlnet_aux\ckpts
[H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_controlnet_aux] | INFO -> Using symlinks: False
[H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_controlnet_aux] | INFO -> Using ort providers: ['CUDAExecutionProvider', 'DirectMLExecutionProvider', 'OpenVINOExecutionProvider', 'ROCMExecutionProvider', 'CPUExecutionProvider', 'CoreMLExecutionProvider']
✅ Protobuf兼容性补丁已成功应用
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json
('Looking for cached Spacy xx_sent_ud_sm.',)### [START] ComfyUI AlekPet Nodes v1.0.88 ###
Node -> ArgosTranslateNode: ArgosTranslateCLIPTextEncodeNode, ArgosTranslateTextNode [Loading]
Node -> ChatGLMNode: ChatGLM4TranslateCLIPTextEncodeNode, ChatGLM4TranslateTextNode, ChatGLM4InstructNode, ChatGLM4InstructMediaNode [Loading]
Node -> DeepLXTranslateNode:  [Loading]
Node -> DeepTranslatorNode: DeepTranslatorCLIPTextEncodeNode, DeepTranslatorTextNode [Loading]
Node -> ExtrasNode: PreviewTextNode, HexToHueNode, ColorsCorrectNode [Loading]
Node -> GoogleTranslateNode: GoogleTranslateCLIPTextEncodeNode, GoogleTranslateTextNode [Loading]
Node -> IDENode: IDENode [Loading]
Node -> PainterNode: PainterNode [Loading]
Node -> PoseNode: PoseNode [Loading]
### [END] ComfyUI AlekPet Nodes ###
[Queue Manager] Queue status: not paused
[tinyterraNodes] Loaded
Efficiency Nodes: Attempting to add Control Net options to the 'HiRes-Fix Script' Node (comfyui_controlnet_aux add-on)...Success!
🐝 Kanibus v1.0.0 - Eye-Tracking ControlNet System Loaded
💫 Features: 14 nodes, GPU optimization, WAN 2.1/2.2 support
Using xformers attention
(RES4LYF) Init
(RES4LYF) Importing beta samplers.
(RES4LYF) Importing legacy samplers.[rgthree-comfy] Loaded 48 epic nodes. 🎉WAS Node Suite: OpenCV Python FFMPEG support is enabled
WAS Node Suite: `ffmpeg_bin_path` is set to: C:\Users\love\scoop\shims\ffmpeg.exe
WAS Node Suite: Finished. Loaded 220 nodes successfully."Believe you deserve it and the universe will serve it." - UnknownImport times for custom nodes:0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\example_node.py0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-zopi0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\websocket_image_save.py0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_AdvancedRefluxControl0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\auto_wan2.2animate_freamtowindow_server0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_ZhipuAIO0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-notes-manager0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-VideoUpscale_WithModel0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-mxtoolkit0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-logic0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_SSLNodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Miaoshouai-Tagger0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\sd-dynamic-thresholding0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-detail-daemon0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\wywywywy-pause0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyLiterals0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_JPS-Nodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\wlsh_nodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-InpaintEasy0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Universal-Styler0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_instantid0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-NunchakuFluxLoraStacker0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_zenid0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_checkpointloader_ext0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_lg_groupexecutor0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_IPAdapter_plus0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_SLK_joy_caption_two0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-vrgamedevgirl0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_sunxAI_facetools0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-WD14-Tagger0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-wormley-nodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-florence20.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Kolors-MZ0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-various0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\AIGODLIKE-ComfyUI-Translation0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-animatediff0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyMath0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_essentials0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-GGUF0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-layerdiffuse0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Holaf0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-custom-scripts0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\efficiency-nodes-comfyui0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-MingNodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-Kwtoolset0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-FramePackWrapper_Plus0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-StreamDiffusion0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-FramePackWrapper_PlusOne0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_queue_manager0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\derfuu_comfyui_moddednodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Flow-Control0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Frame-Interpolation0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-segment-anything-20.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-kjnodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-workspace-manager0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\kanibus0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Impact-Pack0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\rgthree-comfy0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_Comfyroll_CustomNodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_controlnet_aux0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-mmaudio0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-animatediff-evolved0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_LayerStyle_Advance0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\Comfyui-ergouzi-Nodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-inspire-pack0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_tinyterranodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Inference-Core-Nodes0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_Local_Media_Manager0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-MelBandRoFormer0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-WanVideoWrapper0.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-HunyuanVideoWrapper0.1 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_segment_anything0.1 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-tensorops0.1 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-IC-Light0.1 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_layerstyle0.1 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-nunchaku0.1 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-exLoadout0.1 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-utils-nodes0.3 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-VideoHelperSuite0.3 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\Kwai_font_comfyui0.3 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Addoor0.3 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-reactor0.3 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Manager0.5 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui_facetools0.5 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-art-venture0.6 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-mixlab-nodes0.6 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\RES4LYF0.8 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\bilbox-comfyui1.1 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Allor1.4 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-GIMM-VFI1.7 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI-Copilot1.8 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\was-node-suite-comfyui2.1 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\Boyonodes2.3 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfy-mtb3.4 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\ComfyUI_Custom_Nodes_AlekPet5.0 seconds: H:\PythonProjects1\Win_ComfyUI\custom_nodes\comfyui-easy-useContext impl SQLiteImpl.
Will assume non-transactional DDL.
No target revision found.
Starting server[Queue Manager] Task counter set to 1
To see the GUI go to: http://127.0.0.1:8188
FETCH ComfyRegistry Data: 5/105
FETCH ComfyRegistry Data: 10/105
FETCH ComfyRegistry Data: 15/105
FETCH ComfyRegistry Data: 20/105
FETCH ComfyRegistry Data: 25/105
FETCH ComfyRegistry Data: 30/105
FETCH ComfyRegistry Data: 35/105
FETCH ComfyRegistry Data: 40/105
FETCH ComfyRegistry Data: 45/105
FETCH ComfyRegistry Data: 50/105
FETCH ComfyRegistry Data: 55/105
FETCH ComfyRegistry Data: 60/105
FETCH ComfyRegistry Data: 65/105
FETCH ComfyRegistry Data: 70/105
FETCH ComfyRegistry Data: 75/105
FETCH ComfyRegistry Data: 80/105
FETCH ComfyRegistry Data: 85/105
FETCH ComfyRegistry Data: 90/105
FETCH ComfyRegistry Data: 95/105
FETCH ComfyRegistry Data: 100/105
FETCH ComfyRegistry Data: 105/105
FETCH ComfyRegistry Data [DONE]
[ComfyUI-Manager] default cache updated: https://api.comfy.org/nodes
FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json [DONE]
[ComfyUI-Manager] All startup tasks have been completed.


功能验证

  1. AlekPet节点正常加载:所有AlekPet节点都显示为[Loading]状态,没有出现错误
  2. ComfyUI完全启动:服务器成功启动,可以正常访问网页界面
  3. 功能正常使用:包含AlekPet节点的工作流可以正常执行



技术细节解析


猴子补丁的优势

  1. 无需改变库版本:保持了现有的protobuf 6.33.0版本,避免影响其他依赖包
  2. 最小化修改:只需要添加几行代码,不影响原有功能
  3. 动态生效:在程序运行时动态修改,不需要重新编译
  4. 兼容性好:可以同时支持新旧版本的API调用

实现要点

  1. 方法映射:将旧的GetPrototype方法映射到新的GetMessageClass方法
  2. 错误处理:添加了完善的错误处理机制,确保即使出现异常也不会导致程序崩溃
  3. 安全降级:如果所有方法都失败,返回一个默认的空消息类
  4. 版本检测:在应用补丁前先检测是否需要补丁,避免重复操作



总结与经验教训

问题解决的关键

  1. 深入理解错误:通过分析错误信息,准确判断问题的根源
  2. 寻找替代方案:不局限于简单的版本降级,寻找更优雅的解决方案
  3. 考虑全局影响:在解决问题时,充分考虑对其他依赖包的影响
  4. 动态修复:利用Python的动态特性,采用猴子补丁的方式解决兼容性问题

最佳实践建议

  1. 定期备份:在安装新插件前,定期备份环境状态
    pip freeze > requirements_backup_$(date +%Y%m%d_%H%M%S).txt
    

【ComfyUI/SD环境管理指南(一)】:如何避免插件安装导致的环境崩溃与快速修复

  1. 版本管理:对于重要的依赖库,建议锁定版本号,避免意外升级

  2. 错误日志:遇到问题时,详细记录错误日志,便于问题诊断

  3. 测试验证:修复问题后,充分测试相关功能,确保没有引入新的问题



未来展望

随着AI工具和依赖库的不断发展,兼容性问题可能会持续出现。我们建议:

  1. 插件开发者:及时更新插件代码,适配最新版本的依赖库
  2. 工具维护者:建立更好的版本兼容性检测机制
  3. 社区交流:加强开发者和用户之间的交流,及时分享解决方案



参考资料

  1. protobuf官方文档
  2. Python猴子补丁技术
  3. ComfyUI官方仓库
  4. AlekPet节点仓库
  5. 相关问题讨论
  6. PhiCookBook issue讨论

Date: November 10, 2025
Author: AITechLab技术团队
Tags: ComfyUI, protobuf, 兼容性, 猴子补丁, Python, AI艺术创作

本文详细记录了一次ComfyUI中protobuf版本兼容性问题的完整解决方案。通过采用猴子补丁的技术,我们在不改变protobuf版本的情况下,成功解决了AttributeError: 'MessageFactory' object has no attribute 'GetPrototype'错误。希望这个解决方案能为遇到类似问题的开发者和创作者提供有价值的参考。

http://www.dtcms.com/a/593581.html

相关文章:

  • Redis 高级篇(未完结1/3)
  • 华为OD机试 真题 - 【国际移动用户识别码(IMSI)匹配】 - 双机位A卷 (Python C++ JAVA JS GO)
  • 自动更新工期触发器(MYSQL)
  • 企业网站建设的方式有哪些方式网页设计版权怎么写
  • 关键词解释:范数(Norm)
  • 用Python生成个性化的电子邮件签名
  • [PowerShell入门教程] 第2天:变量、管道、对象操作与执行策略详解
  • 做网站运营的职业生涯规划wordpress 水印插件
  • 护照阅读器在酒店行业的应用
  • 继承的概念及使用
  • 建网站的地址手工制作小船
  • 技术选型深度评估:“六行神算”平台在医疗AI项目中的架构适配性
  • VLAN 和 VXLAN
  • PC微信 device uuid 算法
  • 外国网站的浏览器下载网站程序是什么意思
  • 【Docker多节点部署】基于“配置即身份“理念的 Docker 多节点 StarRocks 高可用集群自动化部署方案
  • 如何选择适合企业的数据仓库建模工具?​
  • Ethernet ip转SPI嵌入式板卡-让机器人与单片机互相联动
  • 免费推广网站大全下载安装南山网站-建设深圳信科
  • 【ZeroRange WebRTC】OpenSSL 与 WebRTC:原理、集成与实践指南
  • AnyVP*:企业级远程办公SSL深度技术解析
  • 重庆营销型网站建设多少钱学校网站功能描述
  • Spring @Component 和 @Bean 的区别与最佳实践
  • 怎么给自己公司做网站小影wordpress
  • C# 特性详解
  • 《 Linux 修炼全景指南: 六 》软件包管理器
  • QNAP紧急修复Pwn2Own 2025比赛中遭利用的7个0Day漏洞
  • 大学学部网站建设工作深圳牌申请网站空间
  • LeetCode算法学习之乘积最大子数组
  • 网站建设的业务范围福建住房城乡建设部网站