26

Based on Python-API the requirements I have configured and installed the protocol buffers (as mentioned in http://worthynote.blogspot.com/2011/05/protobuf-compiler-on-mac.html ) and python 2.7. When I ran the command

python examples.py

and still faced the error:

 File "examples.py", line 3, in <module>
import market_proto
File "/Users/siddharthan64/Downloads/android-market-api-py-master/market_proto.py", line 3, in <module>
from google.protobuf import descriptor
ImportError: No module named google.protobuf       

Any idea whats going wrong here?

RubenLaguna
  • 21,435
  • 13
  • 113
  • 151
Siddharthan Asokan
  • 4,321
  • 11
  • 44
  • 80

2 Answers2

45

Use pip:

sudo pip install protobuf

I had the same problem, which is how I found your question, and this fixed it.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Yusuf X
  • 14,513
  • 5
  • 35
  • 47
  • Glad this finally works. Previous versions were not `pip`-installable. – MarkHu Sep 13 '14 at 03:51
  • why do you need to sudo? – Guig Aug 04 '16 at 02:35
  • @Guig You will need sudo if your python is installed under root directories. If your python is installed under your home (or somewhere you own permissions) you don't need sudo. In such cases you need to specify pip to install under the "user" location: `pip install --user module_name`. You can check more here: http://stackoverflow.com/questions/7465445/how-to-install-python-modules-without-root-access. – rph Nov 29 '16 at 03:21
  • What if I get the import error, but protobuf is already installed? – Flair Sep 01 '17 at 22:48
  • Ah I just realize that my Cellar/python is called instead of my bin/python – Flair Sep 01 '17 at 23:28
2

Use conda, if you use anaconda and juypter

conda install -c conda-forge protobuf=3.2.0
saneryee
  • 3,239
  • 31
  • 22