Hadoop:Python客户端驱动程序安装失败,无法连接HiveServer2

17
我正在尝试安装HiveServer2的Python客户端驱动程序:https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-PythonClientDriver 安装说明如下: “可在https://github.com/BradRuderman/pyhs2找到HiveServer2的Python客户端驱动程序,其中包含所有必需的软件包,如SASL和Thrift包装程序。”
然而,运行pip install pyhs2失败了(请参见下面的SASL编译错误信息)。我已经在本地主机上安装并运行了Hadoop 2.2.0。请帮助我安装Python客户端驱动程序。
[root@localhost /]# pip install pyhs2
Requirement already satisfied (use --upgrade to upgrade): pyhs2 in /usr/lib/python2.6/site-packages
Downloading/unpacking sasl (from pyhs2)
  Downloading sasl-0.1.3.tar.gz
  Running setup.py (path:/tmp/pip_build_root/sasl/setup.py) egg_info for package sasl
Downloading/unpacking thrift (from pyhs2)
  Downloading thrift-0.9.1.tar.gz
  Running setup.py (path:/tmp/pip_build_root/thrift/setup.py) egg_info for package thrift
Installing collected packages: sasl, thrift
  Running setup.py install for sasl
    building '_saslwrapper' extension
                                                                                                                                                                                                                                                                                                                                                                    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Isasl -I/usr/include/python2.6 -c sasl/saslwrapper.cpp -o build/temp.linux-x86_64-2.6/sasl/saslwrapper.o
sasl/saslwrapper.cpp:21:23: error: sasl/sasl.h: No such file or directory
sasl/saslwrapper.cpp:51: error: ‘sasl_interact_t’ has not been declared
sasl/saslwrapper.cpp:54: error: ‘sasl_conn_t’ has not been declared
sasl/saslwrapper.cpp:54: error: ‘sasl_secret_t’ has not been declared
sasl/saslwrapper.cpp:57: error: ISO C++ forbids declaration of ‘sasl_conn_t’ with no type
sasl/saslwrapper.cpp:57: error: expected ‘;’ before ‘*’ token
sasl/saslwrapper.cpp:58: error: ‘sasl_callback_t’ does not name a type
sasl/saslwrapper.cpp:71: error: ISO C++ forbids declaration of ‘sasl_secret_t’ with no type
sasl/saslwrapper.cpp:71: error: expected ‘;’ before ‘*’ token
sasl/saslwrapper.cpp: In constructor ‘saslwrapper::ClientImpl::ClientImpl()’:
sasl/saslwrapper.cpp:35: error: class ‘saslwrapper::ClientImpl’ does not have any field named ‘conn’
sasl/saslwrapper.cpp:35: error: class ‘saslwrapper::ClientImpl’ does not have any field named ‘secret’
sasl/saslwrapper.cpp: In destructor ‘saslwrapper::ClientImpl::~ClientImpl()’:
sasl/saslwrapper.cpp:36: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp:36: error: ‘sasl_dispose’ was not declared in this scope
sasl/saslwrapper.cpp:36: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘void saslwrapper::ClientImpl::lastCallback()’:
sasl/saslwrapper.cpp:49: error: ‘SASL_CB_LIST_END’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘bool saslwrapper::ClientImpl::init()’:
sasl/saslwrapper.cpp:83: error: ‘sasl_client_init’ was not declared in this scope
sasl/saslwrapper.cpp:84: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp:85: error: ‘sasl_errstring’ was not declared in this scope
sasl/saslwrapper.cpp:91: error: ‘SASL_CB_GETREALM’ was not declared in this scope
sasl/saslwrapper.cpp:93: error: ‘SASL_CB_USER’ was not declared in this scope
sasl/saslwrapper.cpp:94: error: ‘SASL_CB_AUTHNAME’ was not declared in this scope
sasl/saslwrapper.cpp:97: error: ‘SASL_CB_PASS’ was not declared in this scope
sasl/saslwrapper.cpp:99: error: ‘SASL_CB_PASS’ was not declared in this scope
sasl/saslwrapper.cpp:107: error: ‘SASL_NEED_PROXY’ was not declared in this scope
sasl/saslwrapper.cpp:109: error: ‘callbacks’ was not declared in this scope
sasl/saslwrapper.cpp:109: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp:109: error: ‘sasl_client_new’ was not declared in this scope
sasl/saslwrapper.cpp:110: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp:111: error: ‘sasl_errstring’ was not declared in this scope
sasl/saslwrapper.cpp:115: error: ‘sasl_security_properties_t’ was not declared in this scope
sasl/saslwrapper.cpp:115: error: expected ‘;’ before ‘secprops’
sasl/saslwrapper.cpp:117: error: ‘secprops’ was not declared in this scope
sasl/saslwrapper.cpp:124: error: ‘SASL_SEC_PROPS’ was not declared in this scope
sasl/saslwrapper.cpp:124: error: ‘sasl_setprop’ was not declared in this scope
sasl/saslwrapper.cpp:125: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp:127: error: ‘sasl_dispose’ was not declared in this scope
sasl/saslwrapper.cpp:133: error: ‘SASL_AUTH_EXTERNAL’ was not declared in this scope
sasl/saslwrapper.cpp:134: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp:136: error: ‘sasl_dispose’ was not declared in this scope
sasl/saslwrapper.cpp:141: error: ‘SASL_SSF_EXTERNAL’ was not declared in this scope
sasl/saslwrapper.cpp:142: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp:144: error: ‘sasl_dispose’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘bool saslwrapper::ClientImpl::setAttr(const std::string&, const std::string&)’:
sasl/saslwrapper.cpp:163: error: ‘secret’ was not declared in this scope
sasl/saslwrapper.cpp:164: error: ‘sasl_secret_t’ was not declared in this scope
sasl/saslwrapper.cpp:164: error: expected primary-expression before ‘)’ token
sasl/saslwrapper.cpp:164: error: expected ‘;’ before ‘malloc’
sasl/saslwrapper.cpp: In member function ‘bool saslwrapper::ClientImpl::start(const std::string&, saslwrapper::output_string&, saslwrapper::output_string&)’:
sasl/saslwrapper.cpp:199: error: ‘sasl_interact_t’ was not declared in this scope
sasl/saslwrapper.cpp:199: error: ‘prompt’ was not declared in this scope
sasl/saslwrapper.cpp:205: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp:205: error: ‘sasl_client_start’ was not declared in this scope
sasl/saslwrapper.cpp:206: error: ‘SASL_INTERACT’ was not declared in this scope
sasl/saslwrapper.cpp:208: error: ‘SASL_INTERACT’ was not declared in this scope
sasl/saslwrapper.cpp:209: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp:209: error: ‘SASL_CONTINUE’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘bool saslwrapper::ClientImpl::step(const std::string&, saslwrapper::output_string&)’:
sasl/saslwrapper.cpp:222: error: ‘sasl_interact_t’ was not declared in this scope
sasl/saslwrapper.cpp:222: error: ‘prompt’ was not declared in this scope
sasl/saslwrapper.cpp:227: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp:227: error: ‘sasl_client_step’ was not declared in this scope
sasl/saslwrapper.cpp:228: error: ‘SASL_INTERACT’ was not declared in this scope
sasl/saslwrapper.cpp:230: error: ‘SASL_INTERACT’ was not declared in this scope
sasl/saslwrapper.cpp:231: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp:231: error: ‘SASL_CONTINUE’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘bool saslwrapper::ClientImpl::encode(const std::string&, saslwrapper::output_string&)’:
sasl/saslwrapper.cpp:244: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp:244: error: ‘sasl_encode’ was not declared in this scope
sasl/saslwrapper.cpp:245: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘bool saslwrapper::ClientImpl::decode(const std::string&, saslwrapper::output_string&)’:
sasl/saslwrapper.cpp:265: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp:265: error: ‘sasl_decode’ was not declared in this scope
sasl/saslwrapper.cpp:266: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘bool saslwrapper::ClientImpl::getUserId(saslwrapper::output_string&)’:
sasl/saslwrapper.cpp:282: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp:282: error: ‘SASL_USERNAME’ was not declared in this scope
sasl/saslwrapper.cpp:282: error: ‘sasl_getprop’ was not declared in this scope
sasl/saslwrapper.cpp:283: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘bool saslwrapper::ClientImpl::getSSF(saslwrapper::output_int*)’:
sasl/saslwrapper.cpp:294: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp:294: error: ‘SASL_SSF’ was not declared in this scope
sasl/saslwrapper.cpp:294: error: ‘sasl_getprop’ was not declared in this scope
sasl/saslwrapper.cpp:295: error: ‘SASL_OK’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘void saslwrapper::ClientImpl::addCallback(long unsigned int, void*)’:
sasl/saslwrapper.cpp:311: error: ‘callbacks’ was not declared in this scope
sasl/saslwrapper.cpp: In member function ‘void saslwrapper::ClientImpl::setError(const std::string&, int, const std::string&, const std::string&)’:
sasl/saslwrapper.cpp:323: error: ‘conn’ was not declared in this scope
sasl/saslwrapper.cpp:324: error: ‘sasl_errdetail’ was not declared in this scope
sasl/saslwrapper.cpp:326: error: ‘sasl_errstring’ was not declared in this scope
sasl/saslwrapper.cpp: At global scope:
sasl/saslwrapper.cpp:338: error: variable or field ‘interact’ declared void
sasl/saslwrapper.cpp:338: error: ‘sasl_interact_t’ was not declared in this scope
sasl/saslwrapper.cpp:338: error: ‘prompt’ was not declared in this scope
error: command 'gcc' failed with exit status 1
3个回答

38

pyhs2很棒,它将几个必需的Python包捆绑在一起作为一个dbapi,其中包括sasl。请注意,如果你pip install sasl,你会得到相同的错误。

sasl(Python包)依赖于libsasl2-dev(在Debian/Ubuntu机器上)。您看到的错误是编译器找不到sasl应包装的库。

如果您sudo apt-get install libsasl2-dev并重新运行,问题可能会得到解决。

编辑:根据您的评论,这是使其正常工作的健壮方法:

curl -O -L ftp://ftp.cyrusimap.org/cyrus-sasl/cyrus-sasl-2.1.26.tar.gz
tar xzf cyrus-sasl-2.1.26.tar.gz
cd cyrus-sasl-2.1.26
./configure && make install

不幸的是,我必须在CentOS上运行它,但找不到适用于它的“libsasl2-dev”。 - dokondr
好的,我添加了一种基本的从基础包中安装的方式。 - metaperture

23

Pyhs2需要以下依赖:

  1. gcc-c++

  2. python-devel.x86_64

  3. cyrus-sasl-devel.x86_64

因此,只需运行以下命令:

sudo yum install gcc-c++ python-devel.x86_64 cyrus-sasl-devel.x86_64

sudo pip install pyhs2

4
为什么会被踩?对我来说很有效。这个解决方案有问题吗?请问是什么问题? - Nadine

1
如果您在安装“sasl”时在Windows上遇到错误,请安装预编译的软件包。
从链接https://www.lfd.uci.edu/~gohlke/pythonlibs/#sasl下载python36 x64的sasl软件包。
然后运行pip install sasl-0.2.1-cp36-cp36m-win_amd64.whl

sasl-0.2.1-cp36-cp36m-win_amd64.whl - 这个适用于Windows 8。 - Koshur
@Ceyhun,我遇到了类似的问题。下载文件后,我们应该将文件复制到哪个路径下? - Shiva
@Koshur,下载完成后,文件应复制到哪个路径? - Shiva
@Shiva,据我所知,你可以从任何地方下载。但是,你需要为系统使用的默认Python安装这个Python Wheel文件。很可能 pip [OR pip3 OR pip2] install sasl-0.2.1-cp36-cp36m-win_amd64.whl 可以解决问题。我记不清楚Windows了,但在CentOS中,yum依赖于Python2,因此请考虑pip/Python版本。 - Ceyhun

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接