安装kerberos后python impyla失败

yzxexxkh  于 2021-06-26  发布在  Impala
关注(0)|答案(2)|浏览(482)

我在一台w7机器上,在那里我使用python(anaconda发行版)连接到hadoop集群中使用impyla包的impala。我的公司最近添加了kerberos,结果破坏了我现有的功能。
kerberos之前:

from impala.dbapi import connect
conn = connect( host='localhost', port=21050)
cur = conn.cursor()

cur.execute('SHOW TABLES')
cur.fetchall()

kerberos之后

from impala.dbapi import connect
conn = connect( host='localhost', port=21050, use_kerberos=True,
               kerberos_service_name='impala/myservername')

Traceback (most recent call last):

  File "<ipython-input-13-068c7348729f>", line 2, in <module>
    kerberos_service_name='impala/myservername')

  File "C:\Users\x\AppData\Local\Continuum\Anaconda\lib\site-packages\impala\dbapi\__init__.py", line 47, in connect
    ldap_password, use_kerberos, kerberos_service_name)

  File "C:\Users\x\AppData\Local\Continuum\Anaconda\lib\site-packages\impala\_rpc\hiveserver2.py", line 193, in connect_to_impala
    use_kerberos, kerberos_service_name)

  File "C:\Users\x\AppData\Local\Continuum\Anaconda\lib\site-packages\impala\_rpc\hiveserver2.py", line 166, in _get_transport
    import sasl

ImportError: No module named sasl

我尝试从cmd安装sasl:

>easy_install sasl
Searching for sasl
Reading https://pypi.python.org/simple/sasl/
Best match: sasl 0.1.3
Downloading https://pypi.python.org/packages/source/s/sasl/sasl-0.1.3.tar.gz#md5
=6db4ca3d4fb699cf126a6e6f2f516d8f
Processing sasl-0.1.3.tar.gz
Writing c:\users\x\appdata\local\temp\easy_install-zfqesn\sasl-0.1.3\setup
.cfg
Running sasl-0.1.3\setup.py -q bdist_egg --dist-dir c:\users\x\appdata\loc
al\temp\easy_install-zfqesn\sasl-0.1.3\egg-dist-tmp-cl0non
sasl/saslwrapper.cpp:21:23: fatal error: sasl/sasl.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'C:\\Users\\x\\AppData\\Loc
al\\Continuum\\Anaconda\\Scripts\\gcc.bat' failed with exit status 1
6gpjuf90

6gpjuf901#

我看到你在运行windows。你是在运行cygwin还是其他python?
你试过:
如果使用cygwin,您是否尝试过安装libsasl2-devel?
像cloudera那样从git存储库安装pythonsasl似乎是jenkins环境的一部分?
pip安装git+https://github.com/laserson/python-sasl.git@cython
应该变魔术。
顺便说一句,您正在使用的代码已经被弃用(根据当前的github主机)。
使用

from impala.dbapi import connect
conn = connect( host='localhost', port=21050, auth_mechanism='GSSAPI',
               kerberos_service_name='impala')
pkbketx9

pkbketx92#

我遇到了同样的问题,但我通过安装正确版本的必需库来修复它。
在python库下面安装 pip :

six==1.12.0
bit_array==0.1.0
thrift==0.9.3
thrift_sasl==0.2.1
sasl==0.2.1
impyla==0.13.8

下面的代码正在使用 python 版本 2.7 以及 3.4 .

import ssl
from impala.dbapi import connect
import os
os.system("kinit")
conn = connect(host='hostname.io',
              port=21050,
              use_ssl=True,
              database='default',
              user='urusername',
              kerberos_service_name='impala',
              auth_mechanism = 'GSSAPI')
cur = conn.cursor()
cur.execute('SHOW DATABASES;')
result=cur.fetchall()
for data in result:
    print (data)

相关问题