如何在Python中导入hbase?
我正在尝试在 python 中使用 hbase,并且使用 cloudera 存储库来安装 hadoop/hbase 包。它似乎可以工作,因为我可以使用 shell 访问和处理数据库,但它在 python 中不能完全工作。
我知道要与 hbase 通信,我需要 thrift,所以我从源代码下载并编译了它,我可以将 thrift 导入到 python 中,但是当我执行 from hbase import Hbase
时,我收到模块未找到错误。
有谁知道我需要什么包/模块才能让它工作?我尝试查看 easy_install 和 yum(我使用的是 centos6),但没有成功。我确实找到了一篇文章,其中使用 debain 的人通过执行 sudo aptiutde install python-hbase
安装它,我没有该命令/包,所以我不确定如何获取它(或者如果我必须从源代码编译才能得到它)。
另外,如果有帮助的话,我从cloudera安装了大部分基础内容,并按照http://yannramin.com/2008/07/19/using-facebook-thrift-with-python-and-hbase/
任何帮助/提示/建议都会很棒。
谢谢!
I'm trying to play around with hbase in python and I am using the cloudera repository to install the hadoop/hbase packages. It seems to work as I can access and work on the database using the shell but its not fully working within python.
I know to communicate with hbase I need thrift so I downloaded and complied it from source, I can import thrift into python but when I do from hbase import Hbase
, I get module not found errors.
Does anyone know what package/module I would need to get it to work? I tried to look around easy_install and yum(I'm using centos6) and no luck. I did find an article where a person using debain installed it by doing sudo aptiutde install python-hbase
I don't have that command/package, so I'm not sure how to get it(or if I have to compile from source to get it).
Also if it helps, I installed most of the base from cloudera and followed some instructions(the ones didn't require install) from http://yannramin.com/2008/07/19/using-facebook-thrift-with-python-and-hbase/
Any help/tips/suggestions would be great.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 HappyBase(有关信息,请参阅 https://github.com/wbolster/happybase)。这是通过 Python 与 HBase 交互的现代方式。它涵盖了完整的 Thrift API,但将其包装在一个更好的界面中。
Have a look at HappyBase (see https://github.com/wbolster/happybase for info). It is the modern way to interact with HBase from Python. It covers the complete Thrift API but wraps it in a much better interface.
好吧,我明白了。如果其他人将来遇到这个问题,那实际上很容易。在运行 thrift --gen py Hbase.thrift 的步骤中,它会在运行该命令的位置创建一个 hbase 文件夹。只需将该命令复制到您的默认模块文件夹(或在您运行程序的文件夹中,它应该可以工作)。
Okay, I figured it out. If anyone else is having problems with this in the future its actually pretty easy. In the step where you run
thrift --gen py Hbase.thrift
, it creates a hbase folder in the location you ran that command. Simply take that command and copy it to your default module folder(or in the folder where you run your program and it should work).然后
它现在应该可以工作
then
It should work now