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

Mac下适配Python protobuf 3.19.X的protoc版本降级方案

适配Python protobuf 3.19.6的protoc降级方案

需要降级到的protoc版本

必须将protoc降级到3.19.6版本,protoc版本需要与Python环境中protobuf runtime版本严格匹配,否则会出现生成代码与runtime不兼容的问题(比如你遇到的builder导入错误)。

Homebrew操作步骤(Mac/Linux通用)

  1. 卸载当前安装的高版本protobuf
    brew uninstall protobuf
    
  2. 安装指定的3.19.x版本protobuf(Homebrew提供的protobuf@3.19包默认对应3.19.6)
    brew install protobuf@3.19
    
  3. 强制链接该版本,覆盖系统中可能存在的其他protoc版本
    brew link protobuf@3.19 --force --overwrite
    
  4. 验证版本是否正确
    protoc --version
    
    终端应返回libprotoc 3.19.6

如果protobuf@3.19包的版本不是3.19.6,可以通过以下方式安装精确版本:

  • 先查看protobuf的历史提交记录,找到3.19.6对应的commit哈希
    brew log protobuf
    
  • 直接从对应commit的Formula文件安装
    brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/<替换为3.19.6的commit哈希>/Formula/protobuf.rb
    
  • 安装完成后重复步骤3和4验证版本

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 18:22:12