Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top