2

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.

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
Kemba Walker
  • 21
  • 1
  • 3
  • This question looks similar http://stackoverflow.com/questions/21196648/how-can-i-use-protocol-buffers-for-python-on-windows – Bruce Martin Mar 02 '15 at 04:57
  • libprotoc and python protobuf are two separate packages installed in completely different ways. Are you sure you installed both of them, or did you only install protoc? – Kenton Varda Mar 02 '15 at 07:15

2 Answers2

2

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

export PROTOC_PATH=`which protoc`
Wilfried Kopp
  • 991
  • 7
  • 5
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!

Vicky
  • 271
  • 3
  • 6