ComfyUI MeshGraphormer节点报错:protobuf模块缺失GetMessageClass属性
解决ComfyUI MeshGraphormer-DepthMapPreprocessor节点的AttributeError问题
问题根源
module 'google.protobuf.message_factory' has no attribute 'GetMessageClass'错误的核心是protobuf版本不兼容:你当前使用的protobuf 2.6.1过于陈旧,该方法在这个版本中不存在,而mediapipe 0.10.5依赖的是更高版本的protobuf;同时Python 3.12对低版本protobuf的支持有限。
可行解决方案
1. 安装兼容的protobuf版本
mediapipe 0.10.5适配的protobuf版本范围为3.20.x~3.21.x,强制安装该区间内的稳定版本:
pip install protobuf==3.20.3 --force-reinstall
如果使用虚拟环境,请先激活环境再执行命令,避免全局依赖冲突。
2. 调整mediapipe或Python版本适配
- 若上述操作无效,可升级mediapipe至支持Python 3.12的版本(如0.10.14):
pip install mediapipe==0.10.14 --force-reinstall
- 或降级Python至3.11.x版本(mediapipe 0.10.5对Python 3.11的支持更完善)。
3. 修复节点代码兼容性(极端情况)
如果版本调整后仍报错,直接修改MeshGraphormer-DepthMapPreprocessor节点的代码:
- 找到节点对应的代码文件,定位到调用
message_factory.GetMessageClass的行 - 将其替换为protobuf 3.x兼容的写法:
# 原代码 msg_class = message_factory.GetMessageClass(descriptor) # 修改为 msg_class = message_factory.GetPrototype(descriptor)
4. 清理缓存并重启
执行以下命令清理pip缓存,避免旧版本依赖残留:
pip cache purge
关闭ComfyUI后重新启动,确保新依赖生效。
内容的提问来源于stack exchange,提问作者Mamoth
相关产品推荐
相关产品推荐

