You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Kevin Geiszler (Jira)" <ji...@apache.org> on 2026/01/23 19:18:00 UTC
[jira] [Comment Edited] (HBASE-23644) Thrift2 DemoClient.py is not running
[ https://issues.apache.org/jira/browse/HBASE-23644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18017562#comment-18017562 ]
Kevin Geiszler edited comment on HBASE-23644 at 1/23/26 7:17 PM:
-----------------------------------------------------------------
Hi [~zhangduo], I have not worked on this issue yet since I have been working on HBASE-29457, which involves a similar issue with thrift1/DemoClient.py. For HBASE-29457, I saw the same error as in this issue:
{code:java}
TypeError: a bytes-like object is required, not 'str'{code}
I got around it by changing all of the strings to bytes in the script, but I ran into a different issue later on (see comments in HBASE-29457). Since I'm currently out of ideas for HBASE-29457, I will try working on this issue instead and see how it goes.
was (Author: JIRAUSER302671):
Hi [~zhangduo], I have not worked on this issue yet since I have been working on HBASE-29461, which involves a similar issue with thrift1/DemoClient.py. For HBASE-29461, I saw the same error as in this issue: {color:#172b4d}{color}
{code:java}
TypeError: a bytes-like object is required, not 'str'{code}
{color:#172b4d}{color}I got around it by changing all of the strings to bytes in the script, but I ran into a different issue later on (see comments in HBASE-29461). Since I'm currently out of ideas for HBASE-2946, I will try working on this issue instead and see how it goes.
> Thrift2 DemoClient.py is not running
> ------------------------------------
>
> Key: HBASE-23644
> URL: https://issues.apache.org/jira/browse/HBASE-23644
> Project: HBase
> Issue Type: Improvement
> Affects Versions: 2.2.2
> Reporter: Madhukumar
> Assignee: Kevin Geiszler
> Priority: Minor
> Labels: pull-request-available
> Fix For: 4.0.0-alpha-1
>
> Attachments: DemoClient.py
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> *hbase-examples/py*
> I tried to connect to hbase thrift2 server with python with given demo file DemoClient.py. Issue is the DemoClient.py is not updated for python 3.X. Python 2.X support has ended. Even the github vesrion is not updated, happy to update it.
> I'm using python 3.8. {color:#ff0000}_Attached file for DemoClient.py for python 3.X._ I'm new to Jira and hbase. {color} __
>
> hbase.thrift file that was used to generate gen-py in 2.2.22 release examples does seem like this file hbase-src-2.2.2/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift. _I'm looking for hbase.thrift that was used to get gen-py in py examples. If you can point me to that, that will be great._
> {color:#172b4d}If you generate gen-py using thrift compiler 0.13, this is error that I'm getting when running DemoClient.py, {color}
> {color:#172b4d}Traceback (most recent call last):
> File "DemoClient.py", line 68, in <module>
> client.put(table, put)
> File "/Users/madhuseshadri/Projects/hbase-pyclient-thrift2/gen-py/hbase/THBaseService.py", line 813, in put
> self.send_put(table, tput)
> File "/Users/madhuseshadri/Projects/hbase-pyclient-thrift2/gen-py/hbase/THBaseService.py", line 821, in send_put
> args.write(self._oprot)
> File "/Users/madhuseshadri/Projects/hbase-pyclient-thrift2/gen-py/hbase/THBaseService.py", line 4461, in write
> oprot.writeBinary(self.table)
> File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thrift-0.13.0-py3.8-macosx-10.9-x86_64.egg/thrift/protocol/TBinaryProtocol.py", line 131, in writeBinary
> self.trans.write(str)
> File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thrift-0.13.0-py3.8-macosx-10.9-x86_64.egg/thrift/transport/TTransport.py", line 174, in write
> raise e
> File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/thrift-0.13.0-py3.8-macosx-10.9-x86_64.egg/thrift/transport/TTransport.py", line 170, in write
> self.__wbuf.write(buf)
> TypeError: a bytes-like object is required, not 'str'{color}
> {color:#172b4d}Please note that I'm using 0.13 py client package for thrift. It does not work with thrift==0.9.3 as well.{color}
> Out of the box gen-py that came with 2.2.2 source examples has the following issues working with thrift 0.13 py packages and it is also not code generated for python 3.0 but 2.0.
> * ttypes.py > self.__dict.__iteritems() does not work in python 3.0, so it need to be items
> * xrange does not work in python 3.0 so all that need to be range
>
> thrift compiler 0.13 was available at this point from apache/thrift. It generates the files for python 2.0 it seems because of above two issues because hbase.thrift that is src (link given above), not sure what can be done about this.
> So, I have 0.13 python thrift package which works with python 3.0. DemoClient.py updated to 3.0 but issue is gen-py generation. I don't want to edit these generated py files, so if right hbase.thrift file that works with thrift 0.13.0 compiler, that will be great. Thanks.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)