How to install snappy C libraries on Windows 10 for use with python-snappy in Anaconda?

Khris picture Khris · Mar 23, 2017 · Viewed 11.4k times · Source

I want to install parquet for python using pip within an Anaconda 2 installation on Windows 10.

While installing I ran into the error that is described here, the installer can't find snappy-c.h.

There is no mention on how to install this on Windows in the answers.

I downloaded the Snappy library from http://google.github.io/snappy/ and now I'm stuck.

From my error message I would have assumed that the header files need to be in C:\Users\...\AppData\Local\Continuum\Anaconda2\include, but in the downlaoded archive header and library files are just all in the same folder.

How do I install these properly in the Anaconda folder?

Full error message:

Building wheels for collected packages: python-snappy
  Running setup.py bdist_wheel for python-snappy ... error
  Complete output from command C:\Users\...\AppData\Local\Continuum\Anaconda2\python.exe -u -c "import setup
tools, tokenize;__file__='c:\\users\\...\\appdata\\local\\temp\\pip-build-kl4zef\\python-snappy\\setup.py';f=ge
tattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec
'))" bdist_wheel -d c:\users\...\appdata\local\temp\tmpt8fz9bpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-2.7
  copying snappy.py -> build\lib.win-amd64-2.7
  running build_ext
  building '_snappy' extension
  creating build\temp.win-amd64-2.7
  creating build\temp.win-amd64-2.7\Release
  C:\Users\...\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nol
ogo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Users\...\AppData\Local\Continuum\Anaconda2\include -IC:\Users\...
\AppData\Local\Continuum\Anaconda2\PC /Tpsnappymodule.cc /Fobuild\temp.win-amd64-2.7\Release\snappymodule.obj
  snappymodule.cc
  snappymodule.cc(31) : fatal error C1083: Cannot open include file: 'snappy-c.h': No such file or directory
  error: command 'C:\\Users\\...\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\V
C\\Bin\\amd64\\cl.exe' failed with exit status 2

Answer

TitoOrt picture TitoOrt · May 3, 2017

After a really long and frustrating time trying different methods to get the C files working, I found this site:

http://www.lfd.uci.edu/~gohlke/pythonlibs/

Where C. Gohlke has kindly compiled and uploaded the files for us windows users.

Just download the version you need based on your system and python version. I am using 64bits and python 3.6, so I used the following command from my download folder:

pip install python_snappy-0.5-cp36-cp36m-win_amd64.whl

It worked like a charm :)