Using subprocess for accessing HBase
<p>I'm trying simple commands to access HBase through subprocess in Python.
The following code gives me the wrong output:</p>

<pre><code>import subprocess
cmd=['hbase','shell','list']
subprocess.call(cmd)
</code></pre>

<p>Instead of giving me the list of tables in HBase, I get the following output: </p>

<pre><code> Usage: hbase [&lt;options&gt;] &lt;command&gt; [&lt;args&gt;]
 Options:
  --config DIR    Configuration direction to use. Default: ./conf
  --hosts HOSTS   Override the list in 'regionservers' file

Commands:
Some commands take arguments. Pass no args or -h for usage.
shell           Run the HBase shell
hbck            Run the hbase 'fsck' tool
snapshot        Create a new snapshot of a table
snapshotinfo    Tool for dumping snapshot information
wal             Write-ahead-log analyzer
hfile           Store file analyzer
zkcli           Run the ZooKeeper shell
upgrade         Upgrade hbase
master          Run an HBase HMaster node
regionserver    Run an HBase HRegionServer node
zookeeper       Run a Zookeeper server
rest            Run an HBase REST server
thrift          Run the HBase Thrift server
thrift2         Run the HBase Thrift2 server
clean           Run the HBase clean up script
classpath       Dump hbase CLASSPATH
mapredcp        Dump CLASSPATH entries required by mapreduce
pe              Run PerformanceEvaluation
ltt             Run LoadTestTool
version         Print the version
CLASSNAME       Run the class named CLASSNAME
</code></pre>

<p>How do I give the subprocess command?</p>

<p>If you need to access HBase from Python I strongly suggest you looks at the <strong>happybase</strong> modules.</p>

<p>I have been using them in production for the past 4 years - and they have simplified our ETL tasks.</p>

<p>Out of the box they are Python 2.X, but with a few minutes work - you can upgrade them to Python 3 (useful if you data is UTF-8)</p>

python subprocess hbase