我就废话不多说了,大家还是直接看代码吧~

# 两个依赖包: sasl&thrift
the easier way i find to install sasl on windows 7 is to use the pre-compiled version from here : http://www.lfd.uci.edu/~gohlke/pythonlibs/
there is a direct link to the sasl librairies here : http://www.lfd.uci.edu/~gohlke/pythonlibs/#sasl just pick the one you need.
then you install it using pip :
pip install sasl-0.1.3-cp27-none-win_amd64.whl
 
from setuptools import setup
setup(
  name='pyhs2',
  version='0.6.0',
  author='brad ruderman',
  author_email='bradruderman@gmail.com',
  packages=['pyhs2', 'pyhs2/cloudera', 'pyhs2/tcliservice'],
  url='https://github.com/bradruderman/pyhs2',
  license='license.txt',
  description='python hive server 2 client driver',
  long_description=open('readme.md').read(),
  install_requires=[
    "sasl",
    "thrift",
  ],
  test_suite='pyhs2.test',
  tests_require=["mock"]
)

补充:windows7下给python3安装impyla的艰辛历程

安装环境标题已经给出了,linux下和python2下都很容易安装,我也不知道为什么python3反而这么蛋疼。就直接上干货吧,希望其他人少走弯路。

安装所需依赖

pip install ipython six bit_array thriftpy thrift_sasl==0.2.1 sasl impyla(admin下)

常见报错

error: command ‘c:\program files (x86)\microsoft visual studio 14.0\vc\bin\x86_amd64\link.exe’ failed with exit status 1158

fileexistserror: [winerror 183] 当文件已存在时,无法创建该文件。

link : fatal error lnk1158: cannot run ‘rc.exe’

大致错误分析

一般上面的报错会出现在安装sasl ,thrift_sasl,和bitarray时,推测是源码安装时pip与windows的兼容性问题,这时可以用二进制文件安装,参考中第一个回答下的第二条回复

解决办法

上找到依赖的包的二进制whl文件进行安装,区分cp36和cp37的,然后一个个安装,遇到哪个依赖库报错就在这个网站中找,用它们的包进行安装即可

3/20更新

这几天又发现了新问题:

1. 在重新安装开发环境时出现了

thriftpy.parser.exc.thriftparsererror: thriftpy does not support generating module with path in protocol ‘c’

2. 在linux上安装sasl这个库时,会出现依赖报错:error: command ‘gcc’ failed with exit status 1

感觉着实蛋疼,最后才找到了一劳永逸的解决办法,即使用anaconda安装impyla即可自动解决依赖问题:

conda install -c anaconda impyla

有时安装完impyla后还是会报thrift_sasl不存在的错误,可以用conda install -c anaconda thrift_sasl==0.2.1即可

参考:

以上为个人经验,希望能给大家一个参考,也希望大家多多支持www.887551.com。如有错误或未考虑完全的地方,望不吝赐教。