pycharm+anaconda 连接hive(python3)

通过两大神器,强强联合,轻松掌握python。

1、神器一

anaconda用作包管理.(python模块管理,当然不仅限python模块包的管理)
anaconda下载地址:建议使用最新版本.
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

2、神器二

pycharm:IDE工具(开发工具)
https://download.jetbrains.com/python/pycharm-community-2019.1.1.exe

 

方式一:

1、window + r (window搜索框)
2、输入cmd
3、执行如下指令:下载依赖模块包
pip install thrift
pip install thriftpy
pip install thrift-sasl==0.2.1 ##0.3.0 将报错AttributeError: 'TSocket' object has no attribute 'isOpen'
#pip install thrift_sasl
pip install pure-sasl
pip install impyla
pip install bitarray
pip install twisted
##################impyla (一堆坑) ##如下是代码内容
from impala.dbapi import connect
from impala.util import as_pandas
conn = connect(host='ip地址', port=10000, auth_mechanism='LDAP', user='user', password='password', database='default')
cursor = conn.cursor()
cursor.execute('show databases')
print(as_pandas(cursor))

 

方式二:

1、cmd窗口下:
pip install sasl
pip install thrift
pip install thrift-sasl
pip install PyHive
###################pyhive(比较顺畅)##如下是代码内容
from pyhive import hive
conn = hive.Connection(host='ip地址', port=10000, username='用户名', password='passwd', database='default',auth='LDAP')
cursor = conn.cursor()
cursor.execute('show databases')
for result in cursor.fetchall():
  print(result)


 

注意:


如果安装报 Microsoft Visual C++ 14.0 is required 。
解决方式:
https://www.lfd.uci.edu/~gohlke/pythonlibs/ 去这里下载whl文件。 手工本地安装模块
pip install c:\下载来的\xxx.whl

python版本太多,网上每个人总结的东西都不一样。感觉一堆坑。需要统一的管理,才能更好的学习和掌握。

pycharm+anaconda 连接hive(python3)_第1张图片
 

补充:添加模块包

pycharm+anaconda 连接hive(python3)_第2张图片

 

你可能感兴趣的:(学习博客,python,pycharm,anaconda)