Import caffe results into ImportError: "There is no module named google.protobuf.internal" (import enum_type_wrapper)

I installed Anaconda Python on my machine. When I start Python Interpreter and click "import caffe" in the Python shell, I get the following error:

ImportError: No module named google.protobuf.internal 

I have the following files:

 wire_format_lite_inl.h wire_format_lite.h wire_format.h unknown_field_set.h text_format.h service.h repeated_field.h reflection_ops.h message_lite.h message.h generated_message_util.h extension_set.h descriptor.proto descriptor.h generated_message_reflection.h generated_enum_reflection.h dynamic_message.h descriptor.pb.h descriptor_database.h 

What files do I need for the import to work? Is there a file "internal.h" that is required?

+13
python caffe protocol-buffers
source share
5 answers

This is probably due to the fact that there are two python environments on your computer, one of which is provided by your linux distribution ( pip ), and the other by the anaconda environment ( /home/username/anaconda2/bin/pip ).

Try installing protobuf for both environments to be sure

pip install protobuf

/home/username/anaconda2/bin/pip install protobuf

+30
source share

If you are using Ubuntu, try installing protobuf using

 sudo apt-get install protobuf 

He solved the same problem that I encountered.

+5
source share

If you are using Anaconda, do conda install protobuf

+5
source share

The easiest way to fix this:

 pip install grpcio pip install protobuf 
+1
source share

This is due to confusion in the python environment.

 # check where pip2 $ where pip2 /usr/local/bin/pip2 /usr/bin/pip2 # check where pip $ which pip /usr/local/bin/pip 

There are two pip2 on my computer (I install caffe using python2 env), so I used /usr/local/bin/pip2 install protobuf to solve this problem.

 /usr/local/bin/pip2 install protobuf 
0
source share

All Articles