前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >如何在CDH5.16.2中安装Python Impyla

如何在CDH5.16.2中安装Python Impyla

作者头像
Eights
发布2020-07-10 14:55:54
9330
发布2020-07-10 14:55:54
举报
文章被收录于专栏:Eights做数据Eights做数据

文档编写目的

  • 整理CDH5中安装Impyla的步骤

集群环境

  • CDH5.16.2
  • anaconda3
  • python3.7

组件介绍

  • Impyla:适用于分布式查询引擎的HiveServer2实现(例如Impala,Hive)的Python客户端。

Impyla依赖包
  • six
  • bit_array
  • thriftpy
  • thrift_sasl
  • sasl
安装依赖
  • 安装thrift_sasl需要先执行,否则安装会提示缺少sasl.h文件
代码语言:javascript
复制
yum install gcc-c++ python-devel.x86_64 cyrus-sasl-devel.x86_64

安装其他依赖

代码语言:javascript
复制
pip install bit_array
pip install thriftpy
pip install six
#指定thrift_sasl==0.2.1, 否则连接hive会报错
pip install thrift_sasl
pip install sasl

安装Impyla

  • python3.7不支持最新的版本,需要指定impyla的版本为0.15a1
代码语言:javascript
复制
/usr/local/anaconda3/bin/pip install impyla==0.15a1

Impyla测试

Impala

  • 需要impala的jdbc对应的ip和端口
代码语言:javascript
复制
from impala.dbapi import connect
conn = connect(host='192.168.xx.xx',port=25004)
print(conn)
cursor = conn.cursor()
cursor.execute('show databases')
results = cursor.fetchall()
print(results)
cursor.execute('SELECT distinct id FROM ods.test limit 10')
series_code = cursor.fetchall()
print(series_code)

Hive

代码语言:javascript
复制
from impala.dbapi import connect
conn = connect(host="192.168.xx.xx", port=25005, database="ods", auth_mechanism="PLAIN")
print(conn)
cursor = conn.cursor()
cursor.execute("show databases")
print(cursor.description)
results = cursor.fetchall()
print(results)
cursor.execute("select distinct series_code from ods.test")
print(cursor)
series_code = cursor.fetchall()
print(series_code)
本文参与?腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-02-28,如有侵权请联系?cloudcommunity@tencent.com 删除

本文分享自 Eights做数据 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文档编写目的
    • Impyla依赖包
      • 安装依赖
      • Impyla测试
      相关产品与服务
      专用宿主机
      专用宿主机(CVM Dedicated Host,CDH)提供用户独享的物理服务器资源,满足您资源独享、资源物理隔离、安全、合规需求。专用宿主机搭载了腾讯云虚拟化系统,购买之后,您可在其上灵活创建、管理多个自定义规格的云服务器实例,自主规划物理资源的使用。
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
      http://www.vxiaotou.com