0

我的 python 版本是 3.7,运行后pip3 install happybase,我启动命令hbase thrift start并尝试编写一个简短的 .py 文件,如下所示:

import happybase
connection = happybase.Connection('master')
table = connection.table('jmlr')   #'jmlr' is a table in hbase
for i in table.scan():
        print(i)
table.put('001', {'title':'dasds'})   #error here
connection.close()

即将运行table.put()时,报了这样一个错误:

thriftpy2.transport.base.TTransportException: TTransportException(type=4, message='TSocket read 0 bytes')

并且同时thrift报错:

ERROR [thrift-worker-1] thrift.TBoundedThreadPoolServer: Error occurred during processing of message. java.lang.IllegalArgumentException: Invalid famAndQf provided.

但是刚才我再次运行了这个 python 文件,它给了我一个不同的错误thrift

thrift.TBoundedThreadPoolServer: Thrift error occurred during processing of message. org.apache.thrift.protocol.TProtocolException: Bad version in readMessageBegin

我曾尝试添加类似的参数protocol='compact', transport='framed',但这不起作用,即使table.scan()失败了。里面的一切都hbase shell很好,所以我不知道出了什么问题,我快崩溃了。

4

1 回答 1

0

我遇到了同样的问题并找到了这个解决方案。您甚至需要在 put() 方法中添加空的列限定符(':' 符号作为列族和列限定符之间的分隔符):

table.put('001:', {'title':'dasds'}) 

此外,在第二次运行脚本后,您会收到不同的错误消息,因为 thrift 服务器已经失败。

我希望它会帮助你。

于 2020-06-22T15:57:35.043 回答