导入caffe导致ImportError:"没有名为google.protobuf.internal的模块"(import enum_type_wrapper)

PyN*_*erd 14 python protocol-buffers caffe

我在我的机器上安装了Anaconda Python.当我启动Python解释器并在Python shell中键入"import caffe"时,我收到以下错误:

ImportError: No module named google.protobuf.internal
Run Code Online (Sandbox Code Playgroud)

我有以下文件:

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
Run Code Online (Sandbox Code Playgroud)

我需要哪些文件才能导入?是否需要"internal.h"文件?

Jay*_*wal 32

这可能是因为你的机器中有两个python环境,一个是你的linux发行版(pip)提供的,另一个是anaconda环境(/home/username/anaconda2/bin/pip).

尝试为两种环境安装protobuf

pip install protobuf

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


Mic*_*n G 5

如果您使用的是Ubuntu,请尝试使用安装protobuf

sudo apt-get install protobuf
Run Code Online (Sandbox Code Playgroud)

它解决了我遇到的同样问题.

  • 这对我不起作用,但是`sudo apt-get install python-protobuf`就可以了. (11认同)

小智 5

如果您正在使用Anaconda,请执行 conda install protobuf