我已經安裝了,pyhive,SQLAlchemy的無法連接到Hadoop的沙箱
pip install thrift
pip install PyHive
pip install thrift-sasl
和 因爲pip install sasl
失敗我下載sasl‑0.2.1‑cp27‑cp27m‑win_amd64.whl文件,並在我的Windows 8.1的PC安裝了它。
然後我寫了這個代碼,
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()
這個錯誤,
Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2
我已經從here下載Hortonworks沙箱,並將其用於單獨的服務器。
注:我通過this也去了,但接受的答案是不是爲我工作,因爲從蜂巢進口ThriftHive使導入的錯誤,雖然我已經PIP安裝蜂箱。所以我決定使用pyhive或sqlalchemy
如何連接到配置單元並輕鬆執行查詢?
感謝您的明確答案和您的時間。我會嘗試這一點,並接受如果工作的答案。 :) –
但錯誤說無法啓動SASL。它不說沒有它..無論如何,我會嘗試你所說的 –