gpt4 book ai didi

python - Apache Thrift Python 3 支持

转载 作者:太空狗 更新时间:2023-10-29 22:09:09 25 4
gpt4 key购买 nike

我使用以下方法编译了我的 test.thrift 文件:

thrift -gen py test.thrift

然后我尝试导入创建的文件:

from test.ttypes import *

当我使用 Python 2.7 时,导入有效,但使用 Python 3.4 时,它会引发

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/art/SerTest/addressThrift/gen-py/test/ttypes.py", line11, in <module>
from thrift.transport import TTransport
File "/usr/local/lib/python3.4/dist-
packages/thrift/transport/TTransport.py", line 20, in <module>
from cStringIO import StringIO
ImportError: No module named 'cStringIO'

我试着运行:sudo python3 setup.py install并且有很多异常(exception),似乎都与 python 2 vs 3 问题有关。例如:

File "/usr/local/lib/python3.4/dist-
packages/thrift/transport/TSSLSocket.py", line 99
except socket.error, e:
^
SyntaxError: invalid syntax

此外还有一个警告似乎很重要:

/usr/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'use_2to3'

谷歌搜索 Thrift Python 3 支持似乎自相矛盾。
那些说没有支持的:
Does cql support python 3?
https://issues.apache.org/jira/browse/THRIFT-1857
在这里,我从它的潜台词中了解到:
Thrift python 3.4 TypeError: string argument expected, got 'bytes'
Python 3.4 TypeError: input expected at most 1 arguments, got 3
https://issues.apache.org/jira/browse/THRIFT-2096
那么 Thrift 支持 Python 3.X 吗?如果是这样,我错过了什么?

最佳答案

对此有更好的解决方案。与其等待官方的 python 3 支持,不如使用我们的 thrift python 实现?

https://github.com/eleme/thriftpy

它完全支持 python 3、pypy 和 pypy3。

关于python - Apache Thrift Python 3 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32229690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com