We are unable to access hive while running pytest scripts.
Here are a few details about the script.
from pyhive import hive
conn = hive.Connection(host=“YOUR_HIVE_HOST”, port=PORT, username=“YOU”)
Error info:
Traceback (most recent call last):
File “”, line 1, in
File “/home/rdbi/.local/lib/python2.7/site-packages/pyhive/hive.py”, line 15, in
from TCLIService import TCLIService
File “/home/rdbi/.local/lib/python2.7/site-packages/TCLIService/TCLIService.py”, line 9, in
from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException
ImportError: cannot import name TFrozenDict
Also, we are unable to install two more libraries which are needed.
pip install sasl
pip install thrift-sasl
May I know in which exercise or topic you are trying to run running pytest scripts?
conn = hive.Connection(host=“YOUR_HIVE_HOST”, port=PORT, username=“YOU”)
In this connection you need to give your hostname, portname and your username not just the string.
we want to access hive tables through python. so we started python in web console and just type
from pyhive import hive
but it gives error
Traceback (most recent call last):
File “”, line 1, in
File “/home/rdbi/.local/lib/python2.7/site-packages/pyhive/hive.py”, line 15, in
from TCLIService import TCLIService
File “/home/rdbi/.local/lib/python2.7/site-packages/TCLIService/TCLIService.py”, line 9, in
from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException
ImportError: cannot import name TFrozenDict
while doing research we found some more libraries need to install
pip install sasl
pip install thrift-sasl
we are reffering this link.
and for pytest code we written in pyspark to access the hive.
from pyspark.sql import SparkSession
def test_schema_validation():
sparkSession = SparkSession
.builder
.master(“local”)
.appName(“read data from hive table”)
.enableHiveSupport()
.getOrCreate()
You need to upgrade the Pip version from 20.0.2 to 20.1.1.
By pip install -U pip
But you do not have permissions for upgrading any packages.
Kindly try in your local.
We are using Cloudx environment to demo to customer. It’s important for us to execute pytest in Cloudx environment. Please let us know if there is a way to update in our subscribed Cloudx environment?