question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not compatible with PyHive in Python 3 due to dynamic modify TCLIService

See original GitHub issue

Package versions:

impyla==0.14.0
thrift==0.10.0
thrift-sasl==0.3.0
thriftpy==0.3.9
sasl==0.2.1
PyHive==0.5.0

Reproduce steps:

Python 3.6.3 (default, Oct 24 2017, 14:48:20) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import impala.dbapi
>>> import pyhive.hive
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/guyskk/ym/waimaietl/.venv/lib/python3.6/site-packages/pyhive/hive.py", line 11, in <module>
    from TCLIService import constants
ImportError: cannot import name 'constants'
>>> 

It was caused by https://github.com/cloudera/impyla/blob/master/impala/_thrift_api.py#L80,

# dynamically load the HS2 modules
ExecStats = load(os.path.join(thrift_dir, 'ExecStats.thrift'),
                     include_dirs=[thrift_dir])
TCLIService = load(os.path.join(thrift_dir, 'TCLIService.thrift'),
                       include_dirs=[thrift_dir])
ImpalaService = load(os.path.join(thrift_dir, 'ImpalaService.thrift'),
                         include_dirs=[thrift_dir])
sys.modules[ExecStats.__name__] = ExecStats
sys.modules[TCLIService.__name__] = TCLIService   # <-----here!!!
sys.modules[ImpalaService.__name__] = ImpalaService

And PyHive also includes a TCLIService module, they conflict.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
guyskkcommented, May 18, 2018

@brentonmallen1 swap the import order.

4reactions
celestewang1026commented, Aug 26, 2019

Is there any method can solve this question

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Pyhive module cannot import name hive - Stack Overflow
The file you're starting is named pyhive.py . When you do from pyhive import hive. inside your pyhive.py , then it will try...
Read more >
PyHive - PyPI
PyHive is a collection of Python DB-API and SQLAlchemy interfaces for Presto and Hive. Usage. DB-API. from pyhive import presto # or import...
Read more >
Solved: Re: pyhive connection error: thrift.transport.TTra...
pyhive connection error: thrift.transport. ... on a machine learning project, using pyhive since pyhs2 is not supported by python3.6.
Read more >
[Example code]-Creating Table w PyHive & SqlAlchemy
I'm trying to create a table in a Hive Database using SqlAlchemy ORM. My setting is Python 3.6 with PyHive==0.6.1 and SQLAlchemy==1.2.11 (with...
Read more >
pyhive insert multiple rows
Hive allows only appends, not inserts, into tables, so the INSERT keyword simply ... To update it, the generate.py file can be used:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found