如何在 Windows 10 上安装 snappy C 库以在 Anaconda 中与 python-snappy 一起使用?

问题描述

我想在 Windows 10 上的 Anaconda 2 安装中使用 pip 安装 parquet for python.

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

在安装时我遇到了描述的错误 这里,安装程序找不到snappy-ch.

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

答案中没有提到如何在 Windows 上安装它.

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

我从 http://google.github.io/snappy/ 下载了 Snappy 库,并且现在我被困住了.

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

从我的错误消息中,我假设头文件需要在 C:Users...AppDataLocalContinuumAnaconda2include 中,但在下载的存档中头文件和库文件都在同一个文件夹中.

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

如何在 Anaconda 文件夹中正确安装这些?

How do I install these properly in the Anaconda folder?

完整的错误信息:

Building wheels for collected packages: python-snappy
  Running setup.py bdist_wheel for python-snappy ... error
  Complete output from command C:Users...AppDataLocalContinuumAnaconda2python.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('
', '
');f.close();exec(compile(code, __file__, 'exec
'))" bdist_wheel -d c:users...appdatalocal	emp	mpt8fz9bpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating buildlib.win-amd64-2.7
  copying snappy.py -> buildlib.win-amd64-2.7
  running build_ext
  building '_snappy' extension
  creating build	emp.win-amd64-2.7
  creating build	emp.win-amd64-2.7Release
  C:Users...AppDataLocalProgramsCommonMicrosoftVisual C++ for Python9.0VCBinamd64cl.exe /c /nol
ogo /Ox /MD /W3 /GS- /DNDEBUG -IC:Users...AppDataLocalContinuumAnaconda2include -IC:Users...
AppDataLocalContinuumAnaconda2PC /Tpsnappymodule.cc /Fobuild	emp.win-amd64-2.7Releasesnappymodule.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


解决方案

在尝试不同的方法让 C 文件正常工作之后,我发现了这个网站:

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/

C. Gohlke 为我们的 Windows 用户编译并上传了这些文件.

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

只需根据你的系统和python版本下载你需要的版本即可.我使用的是 64 位和 python 3.6,所以我从我的下载文件夹中使用了以下命令:

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

它就像一个魅力:)

相关文章