我想用pyhive将Python连接到hive。我使用下面的python脚本在本地执行。在
#!/usr/bin/env python
# coding: utf-8
from pyhive import hive
from TCLIService.ttypes import TOperationState
def mysql_connect(host, port, username):
conn = hive.Connection(host=host, port=port, username=username)
return conn.cursor()
cursor = mysql_connect("localhost", 50070, "hduser")
cursor.execute("show databases")
print_log(cursor)
我已经将pyhive呈现到/usr/local/lib/python2.7/dist包,但最终得到以下输出
^{pr2}$编辑 1文件名已从Pyhive更改为Pyhive\u test
尝试的可能解决方案: 1.安装了python2.7和python3.4两个版本。我 已卸载Python3.4,但文件夹似乎仍存在于 /usr/local/lib/。我运行了下面的一些命令来检查python的安装位置以及PYTHONPATH中可用的包
vaibhav@vaibhav-Lenovo-G570:~$ which -a python
/usr/bin/python
vaibhav@vaibhav-Lenovo-G570:~$ python -c "import sys, pprint; pprint.pprint(sys.path)"
['',
'/home/vaibhav',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/home/vaibhav/.local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
2。从提到的链接得到了参考here他们提到在虚拟环境中使用它或者使用干净的水蟒。没有使用任何他们如何和不知道它将如何影响已经存在的配置。在
3.我使用sudo安装了Pyhive,因此我在link之后更改了权限,但仍然遇到了相同的问题。在
您正在启动的文件名为
pyhive.py
。在当你这么做的时候
在}。在
pyhive.py
内,它将尝试从模块导入hive
,而不是从pyhive
库导入{请为要启动的文件命名,并避免使用现有模块/库的名称。在
从docs:
相关问题 更多 >
编程相关推荐