背景
最近工作需要python连接hive,就查了一些资料。发现现在已经开发好的模块有
pyhs2
一般用户python 2 因此我选择了impyla
使用过程中遇到的坑不要太多。
过程
首先粘过来一些安装过程,就是一些依赖模块,我用的是
py 3.6
1、pip install six
2、pip install bit_array
3、pip install thriftpy
thrift (on Python 2.x) or thriftpy (on Python 3.x)
4、pip install thrift_sasl==0.2.1
5、pip install pure-sasl
6、下载bitarray git_hub上有安装步骤
https://github.com/ilanschnell/bitarray
7、pip install impyla
8、pip install pandas
大概就是以上这些吧 我贴以下我的模块库,有一些没用。
坑!
error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”: http://landinghub.visualstudio.com/visual-cpp-build-tools
解决
https://pan.baidu.com/s/1OZUrLvFSIXKkhRF7DOsvPA
14js
下载然后安装
ThriftPy does not support generating module with path in protocol ‘d’
解决 首先看错误信息,然后找到报错代码的最后一行,发现是parser.py报错 处理的话按照以下处理方法
https://blog.csdn.net/sinolover/article/details/77714648
thriftpy.protocol.exc.TProtocolException: TProtocolException(type=4)
之前根据github上的说明,连接的时候没有加auth_mechanism 所以出现了以上错误,现在加上。
conn = connect(host='*',port = 10000,auth_mechanism='PLAIN')
File "C:\Users\guoyiguang\AppData\Local\Programs\Python\Python36\lib\site-packages\thrift_sasl\__init__.py", line 94, in _send_message
self._trans.write(header + body)
TypeError: can't concat str to bytes
这时在init.py”, line 94 添加代码 结果如下