当前位置:
首页 >
安装pyhive包
发布时间:2023/12/31
37
豆豆
一、环境:Windows + Pycharm+ Python37
1、安装pyhive包:sasl、thrift、thrift-sasl、PyHive
Pycharm的Terminal中运行:
其中sasl在Windows安装下安装需要编译环境,为了方便可直接从Link下载编译好的包,直接进行安装,比如python37 64bit电脑选择sasl-0.2.1-cp37-cp37m-win_amd64.whl:
pip install windos路径/sasl-0.2.1-cp37-cp37m-win_amd64.whl2、安装完毕,执行代码会报以下错误
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'解决方案:
在Windows中使用管理员权限打开控制台,在控制执行一段命令即可:
3、就可以使用pyhive来通过python连接hive了。
from pyhive import hiveconn = hive.Connection(host='xxx', port=xxx, username='xxx',password='xxx', database='xxx', auth='LDAP') cursor = conn.cursor() # cursor.execute('show tables') cursor.execute('select count(1) from xx.xxx where xxx="xxx"') for result in cursor.fetchall():print(result)二、环境:Linux + Python36
1、切换成 xxx 用户 su xxx 2、查看python36路径 which python36 3、切换成root用户 exit 4、安装pyhive /xxx/python36 -m pip install pyhive参考链接:[解决方案] Windows pyhive Could not start SASL
总结
- 上一篇: Code::Blocks 17.12 F
- 下一篇: ios 音频录音、上传至7牛、播放及其与