0

I'm following the tutorial at https://developers.google.com/protocol-buffers/docs/pythontutorial .

I've managed to create the addressbook_pb2.py from the proto file. I added addressbook_pb2.py to my project, and when I do import addressbook_pb2 the .py file pops up as I type the name, so I know the program recognizes it.

When I try to run the program, which consists of only the line import addressbook_pb2, I receive the error No module named 'google'. I am extremely new to Python, how would I go about fixing this error? I am running Python 3.4 in Visual Studio 2013

The error is caused at each importing google.protobuf line in my 'addressbook_pb2.py' file

# 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
jalconvolvon
  • 158
  • 1
  • 10
  • What does the adderssbook_pb2.py file look like on the inside? I suspect you may need to tweak either your import or your reference to the module. – saarrrr Oct 02 '15 at 18:22
  • I added the beginning of the file. I receive the error almost immediately in this file too. – jalconvolvon Oct 02 '15 at 18:33
  • 1
    Take a look [here](http://stackoverflow.com/questions/31308812/no-module-named-google-protobuf) and [here](http://stackoverflow.com/questions/21196648/how-can-i-use-protocol-buffers-for-python-on-windows). – psv Oct 06 '15 at 08:49
  • Thank you, I ended up using the command line to install it. My problems ended up being a combination of having multiple Pythons installed (2.7 and 3.4) and just not being familiar with pip, both of which are explained in those posts – jalconvolvon Oct 06 '15 at 19:05
  • Good to hear you solved the issue. I'll post it in an answer for other that read this later. – psv Oct 07 '15 at 07:33

1 Answers1

0

This problem is often caused by having multiple Pythons installed. Solutions to this is explained here and here.

Community
  • 1
  • 1
psv
  • 688
  • 6
  • 19