导入错误:无法从“google.protobuf.internal”导入名称“builder”

ImportError: cannot import name 'builder' from 'google.protobuf.internal'

在使用protobuf时遇到此错误,查看了一下国内好像没有网站讲这个事情

使用版本为python3.9,报错为:



ImportError: cannot import name 'builder' from 'google.protobuf.internal' (C:\Users\xnn\PycharmProjects\pythonProject\venv\lib\site-packages\google\protobuf\internal__init__.py)

谷歌搜索到了相关解决方案,对我来说是有效的:

1. 安装最新的protobuf(我是4.21.1)

pip install protobuf 

2. 将builder.py 从 .../Lib/site-packages/google/protobuf/internal 复制到计算机上的另一个文件夹(我放到了桌面)

3. 安装与项目兼容的 protobuf 版本(对我来说是 3.19.4)

pip install protobuf==3.19.4

4.  将 builder.py 从桌面复制到 Lib/site-packages/google/protobuf/internal


python - 导入错误:无法从“google.protobuf.internal”导入名称“builder” - SegmentFault 思否

0 条评论

请先 登录 后评论
Ruonan
Ruonan

12 篇文章

作家榜 »

  1. 解弘艺 17 文章
  2. 高曾谊 16 文章
  3. 胡中天 14 文章
  4. 旺仔牛奶opo 14 文章
  5. LH 14 文章
  6. 罗柏荣 13 文章
  7. Panda-admin 13 文章
  8. 林晨 12 文章