在 Windows 7 32 位上安装带有 Python 绑定的 Thrift

发布于 2024-12-18 23:08:39 字数 766 浏览 4 评论 0原文

我正在尝试在 Windows 7 上安装 pycassa,一个 Python 中的 Cassandra 客户端。

运行 < code>pip install pycassa 我收到此错误消息:

error: unable to find vcvarsall.bat

深入挖掘,我发现 Python 无法安装 thrift 库和 Python 绑定。人们建议的一种方法是安装 C++ 编译器,例如 Visual Studio 2008 Express,或 Windows 上的 mingw 7、从源代码编译Thrift。

不过,我发现了一个在线编译的Thrift版本。 有没有办法将Thrift的编译版本绑定到Python中,然后在pycassa中使用?或者我必须从源代码编译 thrift 吗?

I am trying to install pycassa, a Cassandra client in Python, on Windows 7.

Running pip install pycassa I got this error message:

error: unable to find vcvarsall.bat

Digging deeper, I found that Python failed to install the thrift library and Python bindings. One way people suggest is to install a C++ compiler, such as Visual Studio 2008 Express, or mingw on Windows 7, and compile Thrift from source.

However, I found an online compiled version of Thrift.
Is there a way to bind the compiled version of Thrift into Python and then use it in pycassa? Or do I have to go through compiling thrift from source?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最近可好 2024-12-25 23:08:39

Thrift 实际上有两个(种类)组件:一个是 Thrift 编译器,它根据给定的接口生成代码;另一个是按语言的库,它为每种语言实现低级 Thrift 协议和传输。

您几乎肯定不需要您链接到的 Thrift 编译器。您确实需要 Thrift python 库; pip 尝试将其安装为 pycassa 的依赖项。它崩溃的原因是 Thrift python 库中包含一个 C 扩展,并且在安装过程中,它会尝试编译该扩展。为了使编译工作,您需要专门做一些事情。

如果您只是出于开发目的这样做,则可以下载最新的 Thrift python 库 手动删除 src/protocol/fastbinary.c,然后从顶级目录运行“setup.py install”。这会比编译和安装扩展慢,但出于开发目的,它可以正常工作。此时您可以使用“pip install --no-deps pycassa”,它不会尝试自动安装 Thrift,而只是安装 pycassa。

如果您在生产环境中执行此操作,您可能需要编译并安装 C 扩展。为此,您需要安装 Visual C++ 2008 Express Edition,查看最新版本的从 SVN 进入 Thrift,转到 lib/py 目录,然后在那里运行“setup.py install”。

Thrift really has two (kinds of) components: there's the Thrift compiler, which generates code given an interface, and then there are the per-language libraries, which implement the low-level thrift protocols and transports for each language.

You almost certainly don't need the Thrift compiler, which is what you linked to. You do need the Thrift python library; pip attempts to install this as a dependency for pycassa. The reason that it's breaking is that there is a C extension that is included in the Thrift python library, and during the installation process, it tries to compile that. For the compilation to work, you need to do a few things specially.

If you're just doing this for development purposes, you can download the latest Thrift python library manually, remove src/protocol/fastbinary.c, and then run 'setup.py install' from the top-level directory. This will be slower than if you have the extension compiled and installed, but for dev purposes, it will work fine. You can use 'pip install --no-deps pycassa' at this point, and it won't try to install Thrift automatically, just pycassa.

If you're doing this for production, you will likely want the C extension to be compiled and installed. To do this, you need to install Visual C++ 2008 Express Edition, check out the latest version of Thrift from SVN, go to the lib/py directory, and run 'setup.py install' there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文