ImportError: cannot import name ‘runtime_version’ from ‘google.protobuf’ (E:\Krita\ComfyUI\ComfyUI3\venv\Lib\site-packages\google\protobuf\__init__.py)

用户在 Krita AI Diffusion 中通过 ComfyUI 1.44(后续尝试 1.50)启动服务器,服务器进程终止并提示缺少 ETN_LoadImageCache 节点。检查日志发现 ImportError 来自 comfyui-tooling-nodes 加载时, tensorflow

快速结论:这个报错通常出现在 Krita AI Diffusion 启动 ComfyUI 服务器时,因依赖版本冲突导致 External Tooling Nodes 自定义节点加载失败。优先排查 google.protobuf 版本是否过旧或与 TensorFlow 不兼容。

问题场景

用户在 Krita AI Diffusion 中通过 ComfyUI 1.44(后续尝试 1.50)启动服务器,服务器进程终止并提示缺少 ETN_LoadImageCache 节点。检查日志发现 ImportError 来自 comfyui-tooling-nodes 加载时,tensorflow 依赖 google.protobufruntime_version 属性缺失。

报错原文

File "E:\Krita\ComfyUI\ComfyUI3\venv\Lib\site-packages\tensorflow\core\framework\attr_value_pb2.py", line 9, in <module>
from google.protobuf import runtime_version as _runtime_version
ImportError: cannot import name 'runtime_version' from 'google.protobuf' (E:\Krita\ComfyUI\ComfyUI3\venv\Lib\site-packages\google\protobuf\__init__.py)

Cannot import E:\Krita\ComfyUI\ComfyUI3\ComfyUI\custom_nodes\comfyui-tooling-nodes module for custom nodes: cannot import name 'runtime_version' from 'google.protobuf'

原因分析

可能原因:google.protobuf 版本过旧(低于 3.20.0 或 4.21.0),不包含 runtime_version 函数。该函数是 protobuf 3.20.0+ 新增的,而 tensorflow(通常是 2.10+ 或 2.15+ 版本)在导入时要求此函数。用户环境中的 protobuf 可能被其他自定义节点或依赖锁定为旧版本。

环境排查

  • 确认 ComfyUI 的虚拟环境路径(如 E:\Krita\ComfyUI\ComfyUI3\venv)。
  • 检查 google.protobuf 当前版本:在虚拟环境的 Python 中运行 import google.protobuf; print(google.protobuf.__version__)
  • 检查 tensorflow 版本:python -c "import tensorflow; print(tensorflow.__version__)"
  • 确认是否同时安装了 comfyui-tooling-nodescomfyui_controlnet_aux 等可能引入 TensorFlow 的自定义节点。
  • 确认 PyTorch 版本为 2.9.1+cu126(已从日志中获取)。

解决步骤

  1. 升级 google.protobuf(可优先尝试):在 ComfyUI 的虚拟环境中执行:
    E:\Krita\ComfyUI\ComfyUI3\venv\Scripts\python.exe -m pip install --upgrade google.protobuf
  2. 若升级后仍报错,尝试安装特定版本(如 4.21.12):
    E:\Krita\ComfyUI\ComfyUI3\venv\Scripts\python.exe -m pip install google-protobuf==4.21.12
  3. 检查 TensorFlow 是否需要降级:比较 TensorFlow 版本与 protobuf 版本兼容性。若 TensorFlow 版本过高(如 2.15+),可尝试降级至 TensorFlow 2.10 或 2.12:
    E:\Krita\ComfyUI\ComfyUI3\venv\Scripts\python.exe -m pip install tensorflow==2.12.0
  4. 如果以上步骤仍不奏效,考虑重置 ComfyUI 环境:删除 venv 文件夹,通过 Krita AI Diffusion 重新安装 ComfyUI(已知版本 1.50 可启动服务器,但可能不支持老显卡,如 GTX 1080 Ti)。

验证方法

重启 Krita AI Diffusion 并尝试启动服务器。检查客户端日志是否不再出现 “Missing required node ETN_LoadImageCache” 错误,以及服务器日志是否没有 ImportError。若正常,Status 指示应为 “Running”。

参考来源

Acly/krita-ai-diffusion #2501

GamsGo AI

AI 工具推荐

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

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

了解 GamsGo AI

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

这个方案解决了吗?

celebrityanime
celebrityanime
文章: 16245

发表回复

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