Python 3.x 从python flask api连接到kerberised hiveserver2
在windows 10中,我们需要帮助解决以下问题。 问题在于sasl库,它是pyhive和impyla的依赖项。 当我们尝试使用安装sasl时 pip安装sasl==0.2.1 或 简易安装sasl 我们在声明时出错- <安装微软Visual Studio C++ 14构建工具> <>我们安装了C++的构建工具, 已安装软件包的图像- 但在安装构建工具之后,我们面临着这个错误Python 3.x 从python flask api连接到kerberised hiveserver2,python-3.x,flask,pyhive,impyla,hiveserver2,Python 3.x,Flask,Pyhive,Impyla,Hiveserver2,在windows 10中,我们需要帮助解决以下问题。 问题在于sasl库,它是pyhive和impyla的依赖项。 当我们尝试使用安装sasl时 pip安装sasl==0.2.1 或 简易安装sasl 我们在声明时出错- 我们安装了C++的构建工具, 已安装软件包的图像- 但在安装构建工具之后,我们面临着这个错误 ```saslwrapper.h(22): fatal error C1083: Cannot open include file: 'sasl/sasl.h': No such
```saslwrapper.h(22): fatal error C1083: Cannot open include file: 'sasl/sasl.h': No such file or directory"
"error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2"```
如果我们安装sasl的预编译轮,我们将得到
回溯:
transport.open()
File "C:\Hive_flask_setup\hive_impyla_py37\hiveapipoc\venv\lib\site-packages\thrift_sasl\__init__.py", line 85, in open
message=("Could not start SASL: %s" % self.sasl.getError()))
thrift.transport.TTransport.TTransportException: Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'
import click
from flask import Flask, jsonify
from impala.dbapi import connect
hostName='host.xxx.corp.com' #gave the original hive host name here
port=10000
database='database'#gave the required database name here
auth='GSSAPI'
userName='user'#gave the actual username here
kerberosService='hive'
class Hive(object):
def connect(self):
return connect(host=hostName,port=port,user=userName,auth_mechanism=auth,kerberos_service_name=kerberosService)
def create_app():
app = Flask(__name__)
#function for eshtablishing connection
def newConnect(query):
conn = Hive()
cur = conn.connect().cursor()
cur.execute(query)
res = cur.fetchall()
return res
# a simple query and a json response
@app.route('/')
def test_endpoint():
connectionResult = newConnect("SHOW TABLES")
return jsonify(message='Test endpoint is working!')
return app
代码片段:
transport.open()
File "C:\Hive_flask_setup\hive_impyla_py37\hiveapipoc\venv\lib\site-packages\thrift_sasl\__init__.py", line 85, in open
message=("Could not start SASL: %s" % self.sasl.getError()))
thrift.transport.TTransport.TTransportException: Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'
import click
from flask import Flask, jsonify
from impala.dbapi import connect
hostName='host.xxx.corp.com' #gave the original hive host name here
port=10000
database='database'#gave the required database name here
auth='GSSAPI'
userName='user'#gave the actual username here
kerberosService='hive'
class Hive(object):
def connect(self):
return connect(host=hostName,port=port,user=userName,auth_mechanism=auth,kerberos_service_name=kerberosService)
def create_app():
app = Flask(__name__)
#function for eshtablishing connection
def newConnect(query):
conn = Hive()
cur = conn.connect().cursor()
cur.execute(query)
res = cur.fetchall()
return res
# a simple query and a json response
@app.route('/')
def test_endpoint():
connectionResult = newConnect("SHOW TABLES")
return jsonify(message='Test endpoint is working!')
return app
已安装Python软件包的列表:
transport.open()
File "C:\Hive_flask_setup\hive_impyla_py37\hiveapipoc\venv\lib\site-packages\thrift_sasl\__init__.py", line 85, in open
message=("Could not start SASL: %s" % self.sasl.getError()))
thrift.transport.TTransport.TTransportException: Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'
import click
from flask import Flask, jsonify
from impala.dbapi import connect
hostName='host.xxx.corp.com' #gave the original hive host name here
port=10000
database='database'#gave the required database name here
auth='GSSAPI'
userName='user'#gave the actual username here
kerberosService='hive'
class Hive(object):
def connect(self):
return connect(host=hostName,port=port,user=userName,auth_mechanism=auth,kerberos_service_name=kerberosService)
def create_app():
app = Flask(__name__)
#function for eshtablishing connection
def newConnect(query):
conn = Hive()
cur = conn.connect().cursor()
cur.execute(query)
res = cur.fetchall()
return res
# a simple query and a json response
@app.route('/')
def test_endpoint():
connectionResult = newConnect("SHOW TABLES")
return jsonify(message='Test endpoint is working!')
return app
- 位数组==1.5.3
- 点击==7.1.2
- 装饰器==4.4.2
- 烧瓶==1.1.2
- gssapi==1.6.9
- 黑斑羚==0.16.2
- 危险==1.1.0
- Jinja2==2.11.2
- MarkupSafe==1.1.1
- pip==20.1.1
- 厚度==3.11
- 纯sasl==0.6.2
- pysasl==0.6.2
- sasl==0.2.1
- setuptools==47.1.0
- 六=1.15.0
- 节俭==0.13.0
- 节约sasl==0.4.2
- 节俭2==0.4.11
- 键入扩展==3.7.4.3
- Werkzeug==1.0.1