Jef*_*ers 5 python google-app-engine grpc
我正在尝试学习 grpc 的基础知识,但使用此 appengine 文档中的示例会导致出现如下错误。我正在Python 2.7.11Mac 上的新 virtualenv 中使用。
当使用 的最新版本时protorpc,six我收到一个错误,当在谷歌搜索此问题时降级到网络上其他人建议的six版本时,我收到一个不同的错误。1.10.0这两个错误如下所示。
hello.py 文件的内容(直接从文档复制)
from protorpc import messages
from protorpc import remote
from protorpc.wsgi import service
package = 'hello'
class HelloRequest(messages.Message):
my_name = messages.StringField(1, required=True)
class HelloResponse(messages.Message):
hello = messages.StringField(1, required=True)
class HelloService(remote.Service):
@remote.method(HelloRequest, HelloResponse)
def hello(self, request):
return HelloResponse(hello='Hello there, %s!' % request.my_name)
# Map the RPC service and path (/hello)
app = service.service_mappings([('/hello.*', HelloService)])
Run Code Online (Sandbox Code Playgroud)
运行最新的 pip 模块(版本如下所示):
$ pip freeze
protorpc==0.11.1
six==1.11.0
$ python hello.py
Traceback (most recent call last):
File "hello.py", line 1, in <module>
from protorpc import messages
File "/tmp/grpc/lib/python2.7/site-packages/protorpc/messages.py", line 1146, in <module>
class Field(six.with_metaclass(_FieldMeta, object)):
TypeError: Error when calling the metaclass bases
metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
Run Code Online (Sandbox Code Playgroud)
使用降级six模块运行(版本如下所示):
$ pip freeze
protorpc==0.11.1
six==1.10.0
$ python hello.py
Traceback (most recent call last):
File "hello.py", line 2, in <module>
from protorpc import remote
File "/tmp/grpc/lib/python2.7/site-packages/protorpc/remote.py", line 117, in <module>
from . import protobuf
File "/tmp/grpc/lib/python2.7/site-packages/protorpc/protobuf.py", line 41, in <module>
from .google_imports import ProtocolBuffer
ImportError: cannot import name ProtocolBuffer
Run Code Online (Sandbox Code Playgroud)
是否有一个神奇的版本组合可以使这个示例工作,或者如果我遵循的文档可能已经过时且错误?
在此先感谢您的任何建议。
| 归档时间: |
|
| 查看次数: |
210 次 |
| 最近记录: |