Windows impyla 踩坑

Windows Impyla 安装

安装各种包

conda install impyla
pip install thriftpy2
#建议使用此版本,高版本出现数据量大读不出来的问题
pip install --no-deps thrift-sasl==0.2.1
conda install pure-sasl

报错

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "D:\pycharm\PyCharm Community Edition 2020.3.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "D:\pycharm\PyCharm Community Edition 2020.3.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/project/project_python/saim2/hive_test.py", line 5, in <module>
    conn = connect(host='10.1.3.18', port=10000, auth_mechanism='PLAIN', database='saim_test', user='hive',password='hive')
  File "D:\anaconda\envs\saim2_hivetest\lib\site-packages\impala\dbapi.py", line 144, in connect
    service = hs2.connect(host=host, port=port,
  File "D:\anaconda\envs\saim2_hivetest\lib\site-packages\impala\hiveserver2.py", line 826, in connect
    transport.open()
  File "D:\anaconda\envs\saim2_hivetest\lib\site-packages\thrift_sasl\__init__.py", line 75, in open
    self._send_message(self.START, chosen_mech)
  File "D:\anaconda\envs\saim2_hivetest\lib\site-packages\thrift_sasl\__init__.py", line 94, in _send_message
    self._trans.write(header + body)
TypeError: can't concat str to bytes

解决方法

更改thrift_sasl下的__init__.py,在第93行94行之间加入
    if (type(body) is str):
      body = body.encode()

加入之后代码

  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://github.com/cloudera/impyla/issues/238

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值