importorror:没有名为impy的模块

2024-05-16 09:43:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经安装了impyla,它的依赖关系遵循this指南。安装似乎很成功,因为现在我可以在Anaconda文件夹(64位Anaconda 4.1.1版本)中看到文件夹“impyla-0.13.8-py2.7.egg”

但当我在python中导入impyla时,会出现以下错误:

>>> import impyla
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named impyla

我已经安装了64位Python2.7.12

有人能解释我为什么要面对这个错误吗?我是Python新手,我花了大量时间在不同的博客上,但是我还没有看到太多的信息。提前谢谢你的时间。


Tags: import版本文件夹most关系egg错误时间
1条回答
网友
1楼 · 发布于 2024-05-16 09:43:38

用法与您提到的稍有不同(从https://github.com/cloudera/impyla

Impyla实现了Python DB API v2.0(PEP 249)数据库接口(有关API的详细信息,请参阅该接口):

from impala.dbapi import connect
conn = connect(host='my.host.com', port=21050)
cursor = conn.cursor()
cursor.execute('SELECT * FROM mytable LIMIT 100')
print cursor.description  # prints the result set's schema
results = cursor.fetchall()

Cursor对象还公开迭代器接口,迭代器接口被缓冲(由Cursor.arraysize控制):

cursor.execute('SELECT * FROM mytable LIMIT 100')
for row in cursor:
    process(row)

您还可以获取pandas数据帧对象

from impala.util import as_pandas
df = as_pandas(cur)
# carry df through scikit-learn, for example

相关问题 更多 >