我安装了,
pip install thrift
pip install PyHive
pip install thrift-sasl自从pip install sasl失败后,我下载了amd64.whl文件并将其安装在我的Windows8.1PC上。
然后我写了这段代码
from pyhive import hive
cursor = hive.connect('192.168.1.232', port=10000, auth='NONE')
cursor.execute('SELECT * from sample_07 LIMIT 5',async=True)
print cursor.fetchall()这就产生了错误:
Traceback (most recent call last):
File "C:/DigInEngine/scripts/UserManagementService/fd.py", line 37, in <module>
cursor = hive.connect('192.168.1.232', port=10000, auth = 'NONE')
File "C:\Python27\lib\site-packages\pyhive\hive.py", line 63, in connect
return Connection(*args, **kwargs)
File "C:\Python27\lib\site-packages\pyhive\hive.py", line 104, in __init__
self._transport.open()
File "C:\Python27\lib\site-packages\thrift_sasl\__init__.py", line 72, 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这段代码给出,
from sqlalchemy import create_engine
engine = create_engine('hive://192.168.1.232:10000/default')
try:
connection = engine.connect()
except Exception, err:
print err
result = connection.execute('select * from sample_07;')
engine.dispose()这个错误,
无法启动SASL: sasl_client_start (-4) SASL(-4)中的错误:没有可用的机制:无法找到回调:2
我已经从这里下载了Hortonworks沙箱,并在一个单独的服务器中使用它。
注意:我也通过了这,但接受的答案并不适用于我,因为从hive导入ThriftHive会导致导入错误,尽管我已经安装了pip。所以我决定用吡啶或金炼金术
如何连接到蜂箱并轻松执行查询?
发布于 2017-02-14 18:29:11
下面是在Windows上构建SASL的步骤,但是您的里程可能有所不同:这在很大程度上取决于您特定系统的路径和可用库。
还请注意,这些说明是针对Python2.7的(我看到您从问题中的路径中使用了这些说明)。
高级概述是您正在安装这个项目:https://github.com/cyrusimap/cyrus-sasl。为此,您必须使用用于构建Python2.7的遗留C++编译器。还有几个其他的步骤可以让它发挥作用。
预构建步骤:
构建步骤:
git clone https://github.com/cyrusimap/cyrus-sasllib子目录。nmake /f ntmakefile STATIC=no prefix=C:\sasl64nmake /f ntmakefile prefix=C:\sasl64 STATIC=no install见下面的说明copy /B C:\sasl64\lib\libsasl.lib /B C:\sasl64\lib\sasl2.libpip install thrift_sasl --global-option=build_ext \ --global-option=-IC:\\sasl64\\include \ --global-option=-LC:\\sasl64\\lib'Include‘locations:
下面是对这些相同步骤的引用,还有一些附加的注释和解释:http://java2developer.blogspot.co.uk/2016/08/making-impala-connection-from-python-on.html。
注意,引用的指令也在include和win32\include子目录中执行步骤(8),您可能也必须这样做。
发布于 2018-12-19 22:24:26
在使用pyhive时,不能以auth="NOSASL"而不是"None"的形式传递身份验证,所以代码应该如下所示:
from pyhive import hive
cursor = hive.connect('192.168.1.232', port=10000, auth='NOSASL')
cursor.execute('SELECT * from sample_07 LIMIT 5',async=True)
print cursor.fetchall()https://stackoverflow.com/questions/42210901
复制相似问题