【sublime】【python】【hive】

安装Python、安装pip

安装sublime、配置sublime

Package Control
SublimeREPL(使可以进行交互,例如input)
  • tools–>build system–>new build system–>修改为如下代码–>保存(例如命名为python3.8)
{
	"encoding": "utf-8",  
	"working_dir": "$file_path",                                                                                      
	"shell_cmd": "C:\\Users\\lorog\\AppData\\Local\\Programs\\Python\\Python38\\python.exe -u \"$file\"",  
	"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",                                                             
	"selector": "source.python"                                                                                       
}
  • preferences–>key bindings–>修改为如下代码–>保存–>F5快捷键运行设置成功

!!!一定要先保存再运行

[
	{
		"keys":["f5"],  
		"caption": "SublimeREPL: Python - RUN current file",  
		"command": "run_existing_window_command", 
		"args": {"id": "repl_python_run",  "file": "config/Python/Main.sublime-menu"}
	}  
]

Autopep8(保存时格式化)

preferences–>setting

"format_on_save": true

连接hive

  1. 安装依赖
pip install pure-sasl
pip install thrift_sasl==0.2.1 --no-deps
pip install thrift==0.9.3
pip install impyla
pip install thriftpy

安装impyla时出现问题Microsoft Visual C++ 14.0 is required
在这里插入图片描述
解决方案
下载Microsoft Visual C++ 14.0

选择默认方式安装即可,电脑也不用重启,直接pip安装所需要的插件就行
地址:https://pan.baidu.com/s/18bjsvBIgBAhn5_6ApMcFew 密码: zkzf

  1. 代码
from impala.dbapi import connect
conn1=connect(host='XXXX',port=10000,database='js',auth_mechanism='PLAIN',user='root',password='123')
cur=conn1.cursor()
cur.execute('SHOW DATABASES')
print(cur.fetchall())

host: 地址
port:端口号
auth_mechanism=‘PLAIN’,一个很重要的参数,必要的
user:用户名
password:密码,可以没有
database:数据库名字

运行报错TypeError: can’t concat str to bytes
解决方法

  • 按照错误,定位到init.py第94行,修改对于body的处理方式
header = struct.pack(">BI", status, len(body))
# 增加对于tody的类型判断,做一些处理
if (type(body) is str):
  body = body.encode()
self._trans.write(header + body)
self._trans.flush()
  1. 成功
    在这里插入图片描述
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值