簡體   English   中英

如何在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_pb2import addressbook_pb2組成的程序時,出現錯誤No module named 'google' 我是Python的新手,我將如何解決該錯誤? 我在Visual Studio 2013中運行Python 3.4

該錯誤是由於我的“ 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引起的。 此處此處說明解決方案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM