一、打包鏡像出錯
docker build總是出錯,如果你用的是python3.7,可以考慮使用python3.6版本
並且注意:選擇thrift-sasl==0.2.1,否則會出現:
AttributeError: 'TSocket' object has no attribute 'isOpen'
二、auth_mechanism
from impala.dbapi import connect host='your_hive_ip' username='your_username' password='your_password' port=21050 data_base_name='your_database_name' db_connection = connect(host=host, port=port, user=username, password=password, database=data_base_name, auth_mechanism='LDAP') # 首先不加auth_mechanism時,該行不會報錯,但是下面的cursor會報錯 # 加上auth_mechanism參數,會出現下面的錯誤 cursor = db_connection.cursor()
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包,然后安裝puresasl,解決方案來自git上:
I solved the issue, had to uninstall the package SASL and install PURE-SASL, when impyla can´t find the sasl package it works with pure-sasl and then everything goes well.
也可以直接下載puresasl包到本地,然后pip install
三、TypeError: can't concat str to bytes
定位到錯誤的最后一條,在init.py第94行(標黃的部分):
header = struct.pack(">BI", status, len(body)) #按照網上的提供的辦法增加對BODY的處理 if (type(body) is str): body = body.encode() self._trans.write(header + body) self._trans.flush()
最后給出各個包的版本:
python3.6.4,bitarray==1.1.0,thrift==0.9.3,thrift-sasl==0.2.1,six==1.12.0,pure-sasl==0.6.2,impyla==0.15.0
更多踩坑過程,請參考