无法在Windows上使用pip安装zbar

时间:2017-04-01 06:41:57

标签: python pip zbar

我试图在我的Windows x64计算机上安装zbar

pip install zbar

这就是我得到的:

Collecting zbar
Using cached zbar-0.10.tar.bz2
Installing collected packages: zbar
Running setup.py install for zbar ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\ruiyang\\appdata\\local\\temp\\pip-build-t2okcg\\zbar\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\ruiyang\appdata\local\temp\pip-4pohzw-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'zbar' extension
creating build
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
C:\Users\Ruiyang\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tczbarmodule.c /Fobuild\temp.win-amd64-2.7\Release\zbarmodule.obj
zbarmodule.c
c:\users\ruiyang\appdata\local\temp\pip-build-t2okcg\zbar\zbarmodule.h(26) : fatal error C1083: Cannot open include file: 'zbar.h': No such file or directory
error: command 'C:\\Users\\Ruiyang\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\ruiyang\\appdata\\local\\temp\\pip-build-t2okcg\\zbar\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\ruiyang\appdata\local\temp\pip-4pohzw-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\ruiyang\appdata\local\temp\pip-build-t2okcg\zbar\

任何人都知道如何解决这个问题?

1 个答案:

答案 0 :(得分:5)

您正尝试使用zbar安装pip个包。执行此操作时,pip会下载源并尝试编译此项目的C / C ++源代码。

要做这样的事情,你需要一个C / C ++编译器并拥有所有依赖项。让pip编译此包可能很复杂。

另一个解决方案是下载嵌入所有二进制文件的二进制轮。 zbar开发人员建议从GitHub webpage

下载二进制轮

您可以下载此binary wheel,其目标是Windows Python 2.7 64位安装。

您所要做的就是:

  • 使用Windows+R打开Windows cli并在cmd
  • 内部运行
  • 转到您已下载whl文件的目录,其中包含cd说明
  • 运行pip install zbar-0.10-cp27-none-win_amd64.whl

例如,命令可以是

pip install zbar-0.10-cp27-none-win_amd64.whl

如果您安装了多个Python,请确保使用正确的pip程序。

你可以为任何包含一些必须编译的代码的包