Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pyhive、sqlalchemy无法连接到hadoop沙盒_Python_Hadoop_Hive_Sqlalchemy_Pyhive - Fatal编程技术网

Python pyhive、sqlalchemy无法连接到hadoop沙盒

Python pyhive、sqlalchemy无法连接到hadoop沙盒,python,hadoop,hive,sqlalchemy,pyhive,Python,Hadoop,Hive,Sqlalchemy,Pyhive,我安装了 pip install thrift pip install PyHive pip install thrift-sasl 及 由于pip安装sasl失败,我下载了该文件并将其安装在我的Windows 8.1 PC上 然后我写了这个代码 from pyhive import hive cursor = hive.connect('192.168.1.232', port=10000, auth='NONE') cursor.execute('SELECT * from sample_

我安装了

pip install thrift
pip install PyHive
pip install thrift-sasl
及 由于
pip安装sasl
失败,我下载了该文件并将其安装在我的Windows 8.1 PC上

然后我写了这个代码

from pyhive import hive
cursor = hive.connect('192.168.1.232', port=10000, auth='NONE')
cursor.execute('SELECT * from sample_07 LIMIT 5',async=True)
print cursor.fetchall()
这会产生以下错误:

Traceback (most recent call last):
  File "C:/DigInEngine/scripts/UserManagementService/fd.py", line 37, in <module>
    cursor = hive.connect('192.168.1.232', port=10000, auth = 'NONE')
  File "C:\Python27\lib\site-packages\pyhive\hive.py", line 63, in connect
    return Connection(*args, **kwargs)
  File "C:\Python27\lib\site-packages\pyhive\hive.py", line 104, in __init__
    self._transport.open()
  File "C:\Python27\lib\site-packages\thrift_sasl\__init__.py", line 72, in open
    message=("Could not start SASL: %s" % self.sasl.getError()))
thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2
这个错误,

无法启动SASL:SASL_客户端_启动(-4)中出现错误SASL(-4):否 可用机制:找不到回调:2

我已经从下载了Hortonworks沙盒,并在单独的服务器中使用它

注意:我也通过了,但接受的答案对我不起作用,因为从hive导入ThriftHive会导致导入错误,尽管我安装了pip hive。所以我决定使用pyhive或sqlalchemy


如何连接到配置单元并轻松执行查询?

以下是在Windows上构建SASL的步骤,但您的里程可能会有所不同:这在很大程度上取决于特定系统的路径和可用库

还请注意,这些说明是特定于Python2.7的(我看到您是从问题中的路径使用的)

高级概述是您正在安装此项目:。为了做到这一点,您必须使用用于构建Python 2.7的遗留C++编译器。要让它发挥作用,还有几个其他步骤

预构建步骤:

  • 安装。使用默认安装路径-注意在接下来的2个步骤中安装它的位置(下面的列表中包括2个选项)
  • 复制到适合您安装的任何包含位置
  • 从同一个include目录中创建一个unistd.h文件
  • 构建步骤:

  • git克隆https://github.com/cyrusimap/cyrus-sasl
  • 打开与步骤1中的编译器一起安装的“VS2013 x64本机工具命令提示符”
  • 将目录更改为步骤4创建的目录,然后更改
    lib
    子目录
  • nmake/f ntmakefile STATIC=no prefix=C:\sasl64
  • nmake/f ntmakefile prefix=C:\sasl64 STATIC=no install
    请参见下面的注释
  • copy/B C:\sasl64\lib\libsasl.lib/B C:\sasl64\lib\sasl2.lib
  • pip install thrift\u sasl--global option=build\u ext\
    --全局选项=-IC:\\sasl64\\include\
    --全局选项=-LC:\\sasl64\\lib
  • “包括”位置:

      程序文件(x86)\公用文件\Python \\\\vc\\VisualC++的微软\\\STND.H“” “%UrrPrxe%\AppDATa\PATH程序\公用\微软\Visual C++ + Python \\\VC”包含“”
    以下是对这些相同步骤的参考,以及一些附加注释和解释:


    引用的指令还执行了
    include
    win32\include
    子目录中的步骤(8),您可能也必须这样做。

    以下是在Windows上构建SASL的步骤,但您的里程可能会有所不同:这在很大程度上取决于特定系统的路径和可用库

    还请注意,这些说明是特定于Python2.7的(我看到您是从问题中的路径使用的)

    高级概述是您正在安装此项目:。为了做到这一点,您必须使用用于构建Python 2.7的遗留C++编译器。要让它发挥作用,还有几个其他步骤

    预构建步骤:

  • 安装。使用默认安装路径-注意在接下来的2个步骤中安装它的位置(下面的列表中包括2个选项)
  • 复制到适合您安装的任何包含位置
  • 从同一个include目录中创建一个unistd.h文件
  • 构建步骤:

  • git克隆https://github.com/cyrusimap/cyrus-sasl
  • 打开与步骤1中的编译器一起安装的“VS2013 x64本机工具命令提示符”
  • 将目录更改为步骤4创建的目录,然后更改
    lib
    子目录
  • nmake/f ntmakefile STATIC=no prefix=C:\sasl64
  • nmake/f ntmakefile prefix=C:\sasl64 STATIC=no install
    请参见下面的注释
  • copy/B C:\sasl64\lib\libsasl.lib/B C:\sasl64\lib\sasl2.lib
  • pip install thrift\u sasl--global option=build\u ext\
    --全局选项=-IC:\\sasl64\\include\
    --全局选项=-LC:\\sasl64\\lib
  • “包括”位置:

      程序文件(x86)\公用文件\Python \\\\vc\\VisualC++的微软\\\STND.H“” “%UrrPrxe%\AppDATa\PATH程序\公用\微软\Visual C++ + Python \\\VC”包含“”
    以下是对这些相同步骤的参考,以及一些附加注释和解释:


    引用的指令还执行了
    include
    win32\include
    子目录中的步骤(8),您可能也必须这样做。

    使用pyhive时,身份验证不能作为
    auth=“nosal”
    传递,而不是
    “None”
    ,因此您的代码应该如下所示:

    from pyhive import hive
    cursor = hive.connect('192.168.1.232', port=10000, auth='NOSASL')
    cursor.execute('SELECT * from sample_07 LIMIT 5',async=True)
    print cursor.fetchall()
    

    使用pyhive时,不能将任何身份验证作为
    auth=“NOSASL”
    传递,而不是
    “None”
    ,因此您的代码应如下所示:

    from pyhive import hive
    cursor = hive.connect('192.168.1.232', port=10000, auth='NOSASL')
    cursor.execute('SELECT * from sample_07 LIMIT 5',async=True)
    print cursor.fetchall()
    

    谢谢你明确的回答和宝贵的时间。如果可行,我将尝试此方法并接受答案。:)但错误显示无法启动SASL。这并不是说没有。。无论如何,我会试试你说的关于python 3的建议。谢谢你的明确回答和时间。如果可行,我将尝试此方法并接受答案。:)但错误显示无法启动SASL。这并不是说没有。。无论如何,我会试试你说的关于python 3的建议?我认为这不是一个身份验证问题,我改为linux,这使开发人员的生活更轻松。我认为这不是一个身份验证问题,我改为linux,这使开发