python 連接 hive 踩坑

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.csdn.net/wx0628/article/details/86550582
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章