Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named google.protobuf

I am trying to run Google's deep dream. For some odd reason I keep getting

ImportError: No module named google.protobuf

after trying to import protobuf. I have installed protobuf using sudo install protobuf. I am running python 2.7 OSX Yosemite 10.10.3.

I think it may be a deployment location issue but i cant find anything on the web about it. Currently deploying to /usr/local/lib/python2.7/site-packages.

like image 971
lecorbu Avatar asked Jul 09 '15 05:07

lecorbu


People also ask

Does Google use Protobuf?

Protocol buffers, or Protobuf, is a binary format created by Google to serialize data between different services. Google made this protocol open source and now it provides support, out of the box, to the most common languages, like JavaScript, Java, C#, Ruby and others.


2 Answers

There is another possibility, if you are running a python 2.7.11 or other similar versions,

sudo pip install protobuf 

is ok.

But if you are in a anaconda environment, you should use

conda install protobuf 
like image 154
Panfeng Li Avatar answered Sep 28 '22 21:09

Panfeng Li


Locating the google directory in the site-packages directory (for the proper latter directory, of course) and manually creating an (empty) __init__.py resolved this issue for me.

(Note that within this directory is the protobuf directory but my installation of Python 2.7 did not accept the new-style packages so the __init__.py was required, even if empty, to identify the folder as a package folder.)

...In case this helps anyone in the future.

like image 37
Dan Nissenbaum Avatar answered Sep 28 '22 20:09

Dan Nissenbaum