Support Questions

Find answers, ask questions, and share your expertise

How to enable a pyhive connection with python 3.5 - SASL issue

avatar
Explorer

Hi,

I'm a Hadoop newbie, so don't shoot me yet. I tried to set a hive connection as described here query-hive-using-python.html

I want to set a hive connection using the hive.Connection with python 3.5.2 but the SASL package seems to cause a problem. I saw on a forum that SASL is compatible only with 2.7 python. Is that right ?

Thank you in advance ! Tom

from pyhive import hive#conn = hive.Connection(host="myserver", port=10000)conn = hive.Connection(host="myserver")import pandas as pd
TTransportException Traceback (most recent call last)in ()1 from pyhive import hive2 #conn = hive.Connection(host="myserver", port=10000)----> 3 conn = hive.Connection(host="myserver") import pandas as pd/opt/anaconda3/lib/python3.5/site-packages/pyhive/hive.py in init(self, host, port, username, database, auth, configuration)102103 try:--> 104 self._transport.open()105 open_session_req = ttypes.TOpenSessionReq(106 client_protocol=protocol_version,/opt/anaconda3/lib/python3.5/site-packages/thrift_sasl/init.py in open(self)70 if not ret:71 raise TTransportException(type=TTransportException.NOT_OPEN,---> 72 message=("Could not start SASL: %s" % self.sasl.getError()))7374 # Send initial responseTTransportException: TTransportException(message="Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found'", type=1)
2 REPLIES 2

avatar
Explorer

We (I should say, IT-team) find a solution

Upgrade of python packages thrift (to version 0.10.0) and PyHive (to version 0.3.0) don’t know why the version we used wasn’t the latest.

Added the following:

<property>  
<name>hive.server2.authentication</name>   
<value>NOSASL</value></property>

in the hive config

from pyhive import hive
conn = hive.Connection(host="myserver",
auth='NOSASL')import pandas as pd
import sys
df = pd.read_sql("SELECT * FROM my_table",
conn)print(sys.getsizeof(df))
df.head()

worked without problem then.

Best,

Thomas

avatar
Contributor
@Thomas Bury

I had similar problem, I had set authentication none and had all the packages required (sasl, thrift, pyhive). I was missing a plain kerberos plugin, which was being used for authentication and had to do the following -
yum install cyrus-sasl-plain
You can read more here - http://grokbase.com/t/hive/user/144tajctxv/error-in-sasl-client-start-4-sasl-4-no-mechanism-availabl...