小编Tec*_*uab的帖子

获得 fastpython protobuf 支持的问题

我看到应该支持为 C++ 生成的 protobuf 阅读器创建 python 包装器。

http://yz.mit.edu/wp/fast-native-c-protocol-buffers-from-python/ 我找到了一种通过设置环境变量来打开支持的简单方法:

PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp

如果我这样做,我会收到以下错误:

    import pyFileLib.db_proc_geo_pb2
  File "C:\sandbox\PrortoBuf\lib\pyFileLib\db_proc_geo_pb2.py", line 6, in <module>
    from google.protobuf import descriptor as _descriptor
  File "c:\python\winpython-64bit-3.6.3.0qt5\python-3.6.3.amd64\lib\site-packages\google\protobuf\descriptor.py", line 46, in <module>
    from google.protobuf.pyext import _message
ImportError: cannot import name '_message'
Run Code Online (Sandbox Code Playgroud)

我看到了一种扩展 protoc 生成器以本地生成 fastpython 输出的方法:https : //github.com/Cue/fast-python-pb

git clone https://github.com/Cue/fast-python-pb.git

cd fast-python-pb

python setup.py install
Run Code Online (Sandbox Code Playgroud)

尝试使用 --fastpython_out 运行 protoc 时出现以下错误:

ModuleNotFoundError: No module named 'plugin_pb2'

--fastpython_out: protoc-gen-fastpython: Plugin failed with status code 1.
Run Code Online (Sandbox Code Playgroud)

看起来这与以下内容有关:https : //groups.google.com/forum/#!topic/protobuf/5Ywz8gwn9Kk

python …

python protocol-buffers python-3.x

2
推荐指数
1
解决办法
4166
查看次数

标签 统计

protocol-buffers ×1

python ×1

python-3.x ×1