PyHive
PyHive copied to clipboard
Can't connect to unsecured hive. SASL error: TTransportException: Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2
This is the code
from pyhive import hive
conn = hive.Connection(host='host_name_with_auth_none' , port=10000, auth='NONE' )
cursor = conn.cursor()
cursor.execute("SHOW TABLES")
for table in cursor.fetchall():
print table
I get the following error:
TTransportException Traceback (most recent call last)
C:\Users\u19m41\AppData\Local\Continuum\Anaconda2\lib\site-packages\pyhive-0.5.0-py2.7.egg\pyhive\hive.pyc in init(self, host, port, username, database, auth, configuration, kerberos_service_name, password, thrift_transport) 157 158 try: --> 159 self._transport.open() 160 open_session_req = ttypes.TOpenSessionReq( 161 client_protocol=protocol_version,
C:\Users\u19m41\AppData\Local\Continuum\Anaconda2\lib\site-packages\thrift_sasl-0.2.1-py2.7.egg\thrift_sasl_init_.pyc in open(self) 70 if not ret: 71 raise TTransportException(type=TTransportException.NOT_OPEN, ---> 72 message=("Could not start SASL: %s" % self.sasl.getError())) 73 74 # Send initial response
TTransportException: Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2
Any idea on why this is happening?
Can you confirm that your HS2's hive.server2.authentication matches what your passing to PyHive's auth parameter?
This is known to work in the Travis build setup, so if there's nothing obvious, you can troubleshoot by comparing your configs with what .travis.yml sets up.
i encontered the same quetion,and i sure the configuration is mated, but the error is always there.
how can i solve it?
plz help me, thanks.
cursor = hive.Connection(host='114.55.41.85').cursor()
thrift.transport.TTransport.TTransportException: Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'
@SaucePan1
@jingw Yes I already confirmed this.
I solved the issue using impyla (instead of pyhive), and getting PURE-SASL instead of SASL. This is the issue I opened on impyla: https://github.com/cloudera/impyla/issues/267
I don't know then, sorry. Glad to hear you solved your issue.
I have solved the same issue installing the package libsasl2-modules
in Ubuntu.
requirements.txt
PyHive==0.5.0
sasl==0.2.1
thrift==0.10.0
thrift-sasl==0.3.0
Dockerfile
FROM python:3.6
RUN apt-get update && apt-get install -y libsasl2-modules libsasl2-dev
WORKDIR /code
ADD requirements.txt .
RUN pip install -r requirements.txt
@servomac Thanks a lot.
@SaucePan1 I had similar issue, I followed most of the steps suggested here in this thread, i.e set authentication to NONE, had latest version of all the packages (sasl, thrift, pyhive) but still did not work. Seems like only piece missing for me was plain kerberos plugin, so i did -
yum install cyrus-sasl-plain
Hi Dhananjay
We are trying to connect hive tables from python ,while connecting facing issues.We are sending our full details please help on this.
we installed python version 2.7.15 and anaconda version 2.7.14 We installed below packages
pip install sasl pip install thrift pip install thrift-sasl pip install PyHive
we written the below code to connect hive tables from python script
from pyhive import hive conn = hive.Connection(host="172.16.17.196", port=10000, username="mapr", database="default") cursor = conn.cursor() cursor.execute("SHOW DATABASES") for result in cursor.fetchall(): use_result(result)
We are getting below error
==========================
Traceback (most recent call last):
File "
@dhananjaymehta That did not worked for me. Does it require any additional configuration?
Hi Dhananjay
We are trying to connect hive tables from python ,while connecting facing issues.We are sending our full details please help on this.
we installed python version 2.7.15 and anaconda version 2.7.14 We installed below packages
pip install sasl pip install thrift pip install thrift-sasl pip install PyHive
we written the below code to connect hive tables from python script
from pyhive import hive conn = hive.Connection(host="172.16.17.196", port=10000, username="mapr", database="default") cursor = conn.cursor() cursor.execute("SHOW DATABASES") for result in cursor.fetchall(): use_result(result)
We are getting below error
==========================
Traceback (most recent call last): File "", line 1, in File "C:\Users\mapr\Anaconda2\lib\site-packages\pyhive\hive.py", line 64, in connect return Connection(*args, **kwargs) File "C:\Users\mapr\Anaconda2\lib\site-packages\pyhive\hive.py", line 162, in init self.transport.open() File "C:\Users\mapr\Anaconda2\lib\site-packages\thrift_sasl__init_.py", line 79, in open message=("Could not start SASL: %s" % self.sasl.getError())) thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2
I'm not sure if it was the exact same error but I got a similar one and solved it by installing SASL manually through this:
Download unofficial from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#sasl (via https://stackoverflow.com/questions/26505882/unable-to-install-sasl-0-1-3-python-package-on-windows-machine/35985464)
This may be sasl's problem, I use https://blog.csdn.net/wenjun_xiao/article/details/104458940 to solve this problem
Thanks @wenjunxiao
sasl package needs to find a plugin folder named "sasl2" which possibly located in site-packages/sasl or Library/bin and needs to be defined in windows registry string SOFTWARE\Carnegie Mellon\Project Cyrus\SASL Library\SearchPath another option is to copy sasl2 into C:\CMU\bin\
refer to https://github.com/cyrusimap/cyrus-sasl/blob/master/lib/common.c#L2472
I want solution!!
I don't understand these registry thing, is this a must to be done manually or it's just something did not go well when packaging?
For other that need a solution, creating a folder locally in C:/CMU/bin did work, it seems crazy to me.
The following works for me
set authentication to nosasl
in your hive-site.xml
and with hypive
conn = hive.Connection(host="hive-server", port=10000, auth='NOSASL', database='default')
I was able to install sasl after follow these steps:
https://dwgeek.com/guide-connecting-hiveserver2-using-python-pyhive.html/
On Windows, I fixed this error by
- Find the sasl2 folder. The simplest way is to go to your Python folder (or Python env folder if you use env) and search for "sasl" using the Windows search tool. I'm using anaconda env and it's at something like "C:\Users\quang.conda\envs\envsName\Library\bin\sasl2"
- Create a folder like C:/CMU/bin and copy the whole sasl2 folder into it. Something like C:/CMU/bin/sasl2
sudo apt-get install sasl2-bin libsasl2-2 libsasl2-dev libsasl2-modules In my case above command solved the issue. It was a dependency issue.