如何解决从python flask API
我们需要帮助来解决Windows 10中的以下问题。 问题在于sasl库,它是pyhive和impyla的依赖项。 当我们尝试使用以下命令安装sasl时
pip install sasl == 0.2.1
或
easy_install sasl
“安装Microsoft Visual Studio C ++ 14构建工具”
因此我们安装了c ++构建工具, 已安装软件包的图像-visual studio build tools
但是我们在安装构建工具后面临着这个错误
```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
已安装的Python软件包列表:
- bitarray == 1.5.3
- click == 7.1.2
- decorator == 4.4.2
- 烧瓶== 1.1.2
- gssapi == 1.6.9
- impyla == 0.16.2
- itsdangerous == 1.1.0
- Jinja2 == 2.11.2
- MarkupSafe == 1.1.1
- pip == 20.1.1
- ply == 3.11
- pure-sasl == 0.6.2
- pysasl == 0.6.2
- sasl == 0.2.1
- setuptools == 47.1.0
- six == 1.15.0
- thrift == 0.13.0
- thrift-sasl == 0.4.2
- thriftpy2 == 0.4.11
- typing-extensions == 3.7.4.3
- Werkzeug == 1.0.1
版本: -操作系统-Windows 10-64位 -python-3.7.9
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。