No module named google.protobuf

2019-01-25 04:50发布

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.

9条回答
走好不送
2楼-- · 2019-01-25 04:59

In my case I

  1. downloaded the source code, compiled and installed:

    $ ./configure
    $ make
    $ make check
    $ sudo make install`
    
  2. for python I located its folder(python) under source code, and ran commands:

    $ python setup.py build
    $ python setup.py install'
    

Not sure if this could help you..

查看更多
在下西门庆
3楼-- · 2019-01-25 05:00

I had this problem to when I had a google.py file in my project files.
It is quite easy to reproduce.
main.py: import tensorflow as tf
google.py: print("Protobuf error due to google.py")

Not sure if this is a bug and where to report it.

查看更多
混吃等死
4楼-- · 2019-01-25 05:01

I got the same error message when I tried to use Tensor Flow. The solution was simply to uninstall Tensor Flow and protobuf:

$ sudo pip uninstall protobuf
$ sudo pip uninstall tensorflow

And reinstall it again: pip installation of Tensorflow. Currently, this is:

# Ubuntu/Linux 64-bit, CPU only:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl

# Mac OS X, CPU only:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0rc0-py2-none-any.whl
查看更多
姐就是有狂的资本
5楼-- · 2019-01-25 05:10

I installed the protobuf with this command:

conda install -c anaconda protobuf=2.6.1

(you should check the version of protobuf)

查看更多
霸刀☆藐视天下
6楼-- · 2019-01-25 05:11

when I command pip install protobuf, I get the error:

Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

If you have the same problem as me, you should do the following commands.

pip install --ignore-installed six sudo pip install protobuf

查看更多
beautiful°
7楼-- · 2019-01-25 05:12

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
查看更多
登录 后发表回答