从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 (将#修改为@)