安装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
- 安装依赖
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
- 代码
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()
- 成功