On Tuesday, 26 August 2014 19:29:37 UTC+1, Feng Xiao wrote:
>
> On Tue, Aug 26, 2014 at 11:03 AM, Dave Hirschfeld <[email protected]
> <javascript:>> wrote:
>
>> Hi,
>> I get the aforementioned error message when trying to use the cpp backend
>> for python with the new version 2.6.0:
>>
>> Python 2.7.5 |Anaconda 2.0.0 (64-bit)| (default, Jul 1 2013, 12:37:52)
>> [MSC v.1500 64 bit (AMD64)] on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> from google.protobuf.internal import cpp_message
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File
>> "build\bdist.win-amd64\egg\google\protobuf\internal\cpp_message.py", line
>> 39, in <module>
>> ImportError: cannot import name _net_proto2___python
>> >>>
>> >>> import os
>> >>> os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION']
>> 'cpp'
>> >>> os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION']
>> '2'
>> >>> import google.protobuf as pb
>> >>> pb
>> <module 'google.protobuf' from
>> 'C:\dev\bin\Anaconda\lib\site-packages\protobuf-2.6.0-py2.7-win-amd64.egg\google\protobuf\__init__.pyc'>
>> >>>
>>
>>
>> Is this a bug? It seems _net_proto2___python may be a leftover from a
>> previous version?
>>
> Why do you import "cpp_message"? I think it's a leftover from the previous
> version and we forgot to remove it...
>
>
>>
>> Also, to compile with VS2008 (required for Python 2.7) I had to change
>> the iterator below to a const_iterator
>>
>>
>> https://code.google.com/p/protobuf/source/browse/trunk/src/google/protobuf/compiler/command_line_interface.cc#1562
>>
> This needs to be fixed. Could you help file an issue?
>
>
I wasn't importing it directly - it was an internal import in protobuf
itself
(possibly when PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION was not set
it caused that particular code path to be taken)
Retrying from scratch with:
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION = cpp
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION = 2
I initially get:
from google.protobuf import descriptor as _descriptor
File "build\bdist.win-amd64\egg\google\protobuf\descriptor.py", line 50,
in <module>
ImportError: No module named pyext
because the __init__.py is missing from pyext. After fixing that I get
from google.protobuf import reflection as _reflection
File "build\bdist.win-amd64\egg\google\protobuf\reflection.py", line 60,
in <module>
ImportError: cannot import name cpp_message
...because that file is also missing. After monkey-patching that I get
from google.protobuf import descriptor as _descriptor
ZipImportError: bad local file header in
C:\dev\bin\Anaconda\lib\site-packages\protobuf-2.6.0-py2.7-win-amd64.egg
...because ZipImport hasn't liked my monkey-patching. If I unzip the egg
and put it ion the site-packages (delete the egg and easy_install.pth
entry) I can then import it fine and it seems to work.
Since you've made the move to git/github I went one better and opened up a
PR for the change:
https://github.com/google/protobuf/pull/1
First PR!
For the non-existant `_net_proto2___python` I opened up issue #2
https://github.com/google/protobuf/issues/2
For the missing `cpp_message.py` I put in a tentative fix in PR #3
https://github.com/google/protobuf/pull/3
where I unconditionally added it to the `py_modules` list. I'm not sure if
thats' the right thing to do, if not you can simply close the PR in favour
of the correct fix.
HTH,
Dave
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.