2015-11-13 175 views
2

我在W7計算機上使用Python(Anaconda發行版)使用Impyla軟件包連接到Hadoop集羣中的Impala。 我的公司最近添加了Kerberos,最終破壞了我的位置。Kerberos安裝後Python Impyla失敗

的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 

回答

1

我看你運行的是Windows。你在運行cygwin還是其他一些python?

你試過:

  1. 如果使用Cygwin,你有沒有嘗試安裝libsasl2-devel的?

  2. 從GIT存儲庫安裝python-sasl,因爲Cloudera似乎是作爲它們的一部分jenkins environment

    PIP安裝的git + https://github.com/laserson/[email protected]

應該做的魔力。

順便說一句,您使用的代碼已被棄用(按照當前的GitHub主)。

使用

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