python 连接 hive 踩坑
1.Python环境
python 3.6.5
pip install pure-sasl
pip install thrift_sasl==0.2.1 --no-deps
pip install thrift==0.9.3
pip install impyla
2.修改源码
错误:
thriftpy.transport.TTransportException: TTransportException(type=1, message="Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'")
解决办法:
主要原因其实还是因为sasl和pure-sasl有冲突,这种情况下,直接卸载sasl包就行了。
pip uninstall SASL
错误:
TypeError: can't concat str to bytes
解决办法:
定位 thrift_sasl/__init__.py 92行 修改为:
def _send_message(self, status, body):
header = struct.pack(">BI", status, len(body))
if (type(body) is str):
body = body.encode()
self._trans.write(header + body)
self._trans.flush()
参考博客 https://blog.youkuaiyun.com/wx0628/article/details/86550582