google.protobuf installed, but module not found

点点圈 提交于 2020-01-02 09:27:24

问题


I have installed protobuf but when I run my script that uses pb.py it complains:

from google.protobuf import descriptor as _descriptor
    ImportError: No module named google.protobuf

However when I run protoc --version I see libprotoc 2.6.1 The previous posts say to see if protobuf is within the path of python, I can't find the protobuf path though.
Can anyone tell me what I'm doing wrong? I'm running Yosemite.


回答1:


I had that exact problem yesterday. Basically you have protoc already, you just need to let Python see it. Here's how to do it:
In your terminal: export PROTOC_PATH = 'which protoc' and then echo $PROTOC_PATH and then add PROTOC_PATH to your .bash_profile.

Hope that helps!




回答2:


Be careful how the quotes are rendered, they should be BACKquotes:

export PROTOC_PATH=`which protoc`


来源:https://stackoverflow.com/questions/28802358/google-protobuf-installed-but-module-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!