首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

Thrift安装中出现的有关问题(For HBase)

2012-10-18 
Thrift安装中出现的问题(For HBase)安装巨简单:进入thrift根目录 ./configure?-- ./make -- make instal

Thrift安装中出现的问题(For HBase)

安装巨简单:

进入thrift根目录 ./configure?--> ./make --> make install

?

为了在某些简单环境下,决定采用python来访问hbase

?

1、在make的时候出现fatal error: Python.h: No such file or directory的错误:

答:没有安装python-dev的包,运行sudo apt-get install python-dev 即可

?

2、提示找不到各种包

答:运行完

thrift?--gen?py?/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift??

会出现gen-py,需要把里面的hbase文件夹拷到/usr/lib/python2.7/dist-packages目录下

此外,需要把

thrift-0.6.1/lib/py/build/lib.linux-x86_64-2.7/thrift拷到/usr/lib/python2.7/dist-packages

(以上是在ubuntu中的测试,在suse中,需放入/usr/local/lib/python2.7/site-packages下才有效)

?

当然,你也可以直接用ln -s?做个软连接

或者不放在上述system lib级别的目录中,用sys.path.append也行, 要想永久有效的话,就把append语句放在PYTHONPATH中

?

3、IDE还是会报找不到包

答:这个就比较诡异了,没关系,我建议你关闭ide,再打开。我用的是Aptana Studio 3

?

?

--------------------有问题再继续------------------

这边顺便提一个在用python基于stream写MR程序的时候,有时会出现问题,需要在开头加上:

#!/usr/bin/env python

关于python写MR,推荐一篇文章,简单,详细 http://www.michael-noll.com/tutorials/writing-an-hadoop-mapreduce-program-in-python/

?

thrift访问中的问题:

1、二进制问题

???需要使用binascii模块进行转

???

import binascii    bin = lambda n:(n > 0) and (bin(n/2) + str(n%2)) or ''    s = 'hello world,this is python'  s_16 = binascii.b2a_hex(s)  s_10 = int(s_16,16)  s_2 = bin(s_10)  print s_2    s_10 = int(s_2,2)  s_16 = '%x'%(s_10)  s = binascii.a2b_hex(s_16)  print s 

?

代码引自http://iyuan.iteye.com/blog/1226791

?

?

热点排行