背景:python里连接hive对应的包是pyhive,但根据hive客户端的不同的需要引用不同的子模块。部门在hive安装了hiveserver2,并在centos运行,但在连接的时候出现错误module 'six' has no attribute 'ensure_binary'。解决问题后进行记录。
(1) 安装模块:
(2) 运行代码:
from pyhive import hive
a=''#写hive的ip
conn = hive.Connection(host=a, port=10000, username='root', database='default')
cursor = conn.cursor()
cursor.execute('show tables')
for result in cursor.fetchall():
print(result)
(3) 报错:
module 'six' has no attribute 'ensure_binary'
(4) 解决:
报错信息提示是six模块的问题,更新模块:
pip install --upgrade six
(5) 重新运行(2)的代码,运行成功!