python protobufs - avoid the install step ?
Posted
by
orion elenzil
on Stack Overflow
See other posts from Stack Overflow
or by orion elenzil
Published on 2011-01-11T02:06:21Z
Indexed on
2011/01/11
21:53 UTC
Read the original article
Hit count: 426
i'm writing a small python utility which will be consumed by moderately non-technical users and which needs to interface w/ some protobufs.
ideally, i would like the only prerequisites to using this on a local machine to be:
have python installed
* have an SVN checkout of the repository
* run a simple bash script to build the local proto .py definitions
* run "python myutility"
i'm running into trouble around importing descriptor_pb2.py, tho. i've seen Why do I see "cannot import name descriptor_pb2" error when using Google Protocol Buffers? , but would like to avoid adding the additional prerequisite of having run the proto SDK installer. i've modified the bash script to also generate descriptor_pb2.py in the local heirarchy, which works for the first level of imports from my other _pb2.py files, but it looks like descriptor_pb2.py itself tries to import descriptor_pb2 can't find it:
$ python myutility.py
Traceback (most recent call last):
File "myutility.py", line 4, in <module>
import protos.myProto_pb2
File "/myPath/protos/myProto_pb2.py", line 8, in <module>
from google.protobuf import descriptor_pb2
File "/myPath/google/protobuf/descriptor_pb2.py", line 8, in <module>
from google.protobuf import descriptor_pb2
ImportError: cannot import name descriptor_pb2
my local folder looks like:
* myutility.py
* google/
* protobuf/
* descriptor.py
* descriptor_pb2.py
* protos
* myProto_ob2.py
also, i'm a python n00b, so it's possible i'm overlooking something obvious.
tia, orion
© Stack Overflow or respective owner