windows10上通过python3远程连接hive
发布日期:2021-05-15 21:32:07
浏览次数:32
分类:技术文章
本文共 1706 字,大约阅读时间需要 5 分钟。
注意:impyla 既可以连接impala, 也可以连接hive
环境 : windows10
python版本:3.6 hive版本:1.1impyla安装过程
安装依赖
pip3 install bit_array pip3 install thrift pip3 install thriftpy pip3 install pure_sasl pip install --no-deps thrift-sasl==0.2.1 安装impyla pip3 install impyla连接Hive
# -*-coding:utf-8 -*-from impala.dbapi import connectconn = connect(host='ip', port=10000, database='default', user='hive', password='hive', auth_mechanism="PLAIN")cur = conn.cursor()cur.execute('show tables')print(cur.fetchall())
注意事项
1.重点不要安装sasl,否则会提示报错
卸载方式:pip3 uninstall sasl 2.在安装过程中,如果出现包安装失败的情况,可以下载whl包进行安装,下载链接:https://www.lfd.uci.edu/~gohlke/pythonlibs/ 安装方式:pip3 install 包的绝对路径 3.如果在安装过程中,出现任何包安装失败的问题,可以先将之前所有安装过的包统统卸载,再按顺序依次安装一次问题集锦
- impyla (0.14.0) ERROR - ‘TSocket’ object has no attribute ‘isOpen’ 这个问题的原因是thrift-sasl版本过高导致的,将其换成0.2.1的版本即可 pip3 install thrift-sasl==0.2.1
- thriftpy2.protocol.exc.TProtocolException: TProtocolException(type=4) 这是由于auth_mechanism设置的问题导致的,加上或将其改为auth_mechanism="PLAIN"即可
- TypeError: can’t concat str to bytes 修改 thrift-sasl init.py,在第94行之前加上以下语句即可:
def _send_message(self, status, body): header = struct.pack(">BI", status, len(body)) if (type(body) is str): body = body.encode() self._trans.write(header + body) self._trans.flush()
- 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下采用pyhive连接方式提出的错误,正如前言所述,可能需要修改对应的配置文件,也可能sasl根本就不支持Windows,建议改用impyla形式连接
- thriftpy.parser.exc.ThriftParserError: ThriftPy does not support generating module with path in protocol ‘c’ 修改thriftpy包下\parser\parser.py"中第488行代码,将"if url_scheme == ‘’:" 修改为"if len(url_scheme) <=1:"即可
转载地址:https://blog.csdn.net/qq_30868737/article/details/108009736 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
逛到本站,mark一下
[***.202.152.39]2024年04月18日 14时45分15秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
查看Firefox中的缓存
2019-04-27
http header头设置反向代理不缓存
2019-04-27
配置MySQL主从复制
2019-04-27
CI框架如何删除地址栏的 index.php
2019-04-27
expires与etag控制页面缓存的优先级
2019-04-27
取消掉Transfer-Encoding:chunked
2021-06-30
HTTP协议中的Tranfer-Encoding:chunked编码解析
2021-06-30
JavaScript面向对象编程
2021-06-30
在Javascript中使用面向对象的编程
2021-06-30
由浅入深剖析.htaccess
2021-06-30
php函数serialize()与unserialize()
2021-06-30
PHP Webservice的发布与调用
2021-06-30
php反射类 ReflectionClass
2021-06-30
php扩展xdebug基本使用
2019-04-27
为 PHP 应用提速、提速、再提速
2019-04-27
Linux下gedit显示行号
2019-04-27
《Advanced PHP Programming》读书笔记
2019-04-27
让我们谈谈RAID
2019-04-27
jQuery日期选择器插件date-input
2019-04-27
PHP使用curl_multi_add_handle并行处理
2019-04-27