Search code examples
pythonhbaseapache-phoenix

Python compatibility issue while running Apache Phoenix command


I Installed Hadoop , Pig, Hive, HBase and Zookeeper successfully. I installed Apache Phoenix to access HBase. Below are my PATH variables.

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH="$PATH:$JAVA_HOME/bin"
export PATH="/home/vijee/anaconda3/bin:$PATH"

export HADOOP_HOME=/home/vijee/hadoop-2.7.7
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH="$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin"
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"

export ZOOKEEPER_HOME=/home/vijee/apache-zookeeper-3.6.2-bin
export PATH=$PATH:$ZOOKEEPER_HOME/bin

export HBASE_HOME=/home/vijee/hbase-1.4.13-bin
export PATH=$PATH:$HBASE_HOME/bin

export PHOENIX_HOME=/home/vijee/apache-phoenix-4.15.0-HBase-1.4-bin
export PATH=$PATH:$PHOENIX_HOME/bin

I copied phoenix-4.15.0-HBase-1.4-client.jar, phoenix-4.15.0-HBase-1.4-server.jar, phoenix-core-4.15.0-HBase-1.4.jar to HBase lib directory and restarted Hbase and Zookeeper. When I run the below Phoenix command, it is throwing error

(base) vijee@vijee-Lenovo-IdeaPad-S510p:~/apache-phoenix-4.15.0-HBase-1.4-bin/bin$ psql.py localhost $PHOENIX_HOME/examples/WEB_STAT.sql $PHOENIX_HOME/examples/WEB_STAT.csv $PHOENIX_HOME/examples/WEB_STAT_QUERIES.sql
Traceback (most recent call last):
  File "/home/vijee/apache-phoenix-4.15.0-HBase-1.4-bin/bin/psql.py", line 57, in <module>
    if hbase_env.has_key('JAVA_HOME'):
AttributeError: 'dict' object has no attribute 'has_key'

My Python Version

$ python --version
Python 3.8.3

I know it is Python compatability issue and psql.py is written for Python 2.x.

How to resolve this issue?


Solution

  • Briefly searching, it looks like HBase-1.4 is from 2017, while the latest stable is 2.2.5 .. the release notes imply that it works with Python 3

    Consider simply using the newer jar Apache Archive Link for stable files

    At least psql.py in the latest Apache Phoenix code does appear to support Python 3 https://github.com/apache/phoenix/blob/master/bin/psql.py so you should be able to get a newer version than you have which will work with it.

    This can be seen in the latest commit to it


    If you must use 1.4.x, you may be able to run psql.py with Python 2 instead. Most operating systems will accept having them installed in parallel, though it may make some dependency management confusing and it is not a maintainable solution.