ImportError: No module named google.protobuf
Solution 1:
Had the same issue and I resolved it by using :
conda install protobuf
Solution 2:
You should run:
pip install protobuf
That will install Google protobuf and after that you can run that Python script.
As per this link.
Solution 3:
I also have this issue and have been looking into it for a long time. It seems that there is no such problem on python 3+. The problem is actually on google.protobuf
Solution 1:
pip uninstall protobuf
pip uninstall google
pip install google
pip install protobuf
pip install google-cloud
Solution 2:
create an __init__.py
in "google" folder.
cd /path/to/your/env/lib/python2.7/site-packages/google
touch __init__.py
Hopefully it will work.
Solution 4:
The reason for this would be mostly due to the evil command pip install google
. I was facing a similar issue for google-cloud
, but the same steps are true for protobuf
as well. Both of our issues deal with a namespace conflict over the 'google' namespace.
If you executed the pip install google
command like I did then you are in the correct place. The google
package is actually not owned by Google which can be confirmed by the command pip show google
which outputs:
Name: google
Version: 1.9.3
Summary: Python bindings to the Google search engine.
Home-page: http://breakingcode.wordpress.com/
Author: Mario Vilas
Author-email: [email protected]
License: UNKNOWN
Location: <Path where this package is installed>
Requires: beautifulsoup4
Because of this package, the google
namespace is reserved and coincidentally google-cloud
also expects namespace google > cloud
and it results in a namespace collision for these two packages.
See in below screenshot namespace of google-protobuf
as google > protobuf
Solution :- Unofficial google
package need to be uninstalled which can be done by using pip uninstall google
after this you can reinstall google-cloud
using pip install google-cloud
or protobuf
using pip install protobuf
FootNotes :- Assuming you have installed the unofficial google
package by mistake and you don't actually need it along with google-cloud
package. If you need both unofficial google
and google-cloud
above solution won't work.
Furthermore, the unofficial 'google' package installs with it 'soupsieve' and 'beautifulsoup4'. You may want to also uninstall those packages.
Let me know if this solves your particular issue.
Solution 5:
On Mac OS - Installing tensorflow 1.3 - it will automatically remove other protobuf installs and install protobuf 3.4. However, this does not work and neither does installing or downgrading to any other protobuf version.
However I found a solution. Not sure why this works - but on Mac OS this solved it.
pip install google