如何在 Visual Studio 2013 中为 Python 中的协议缓冲区添加 'google' 模块?

How do I add a 'google' module for protocol buffers in Python in Visual Studio 2013?

我正在学习 https://developers.google.com/protocol-buffers/docs/pythontutorial 上的教程。

我已经成功地从原型文件创建了 addressbook_pb2.py。我将 addressbook_pb2.py 添加到我的项目中,当我执行 import addressbook_pb2 时,会在我键入名称时弹出 .py 文件,因此我知道程序可以识别它。

当我尝试 运行 仅包含行 import addressbook_pb2 的程序时,我收到错误 No module named 'google'。我是 Python 的新手,我该如何解决这个错误?我 运行宁 Python 3.4 Visual Studio 2013

错误是在我的 'addressbook_pb2.py' 文件中的每个 importing google.protobuf 行引起的

# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: addressbook.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf import descriptor_pb2

这个问题一般是安装了多个Python导致的。 here and here.

解释了对此的解决方案