在Windows上使用pip安装zbar失败了。

6

我正在尝试在我的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个回答

5
您正在尝试使用pip安装zbar包。在这样做时,pip会下载源代码并尝试编译此项目的C/C++源代码。
要执行此操作,您需要一个C/C++编译器并拥有所有依赖项。让pip编译此软件包可能很复杂。
另一种解决方案是下载嵌入所有二进制文件的二进制轮。zbar开发人员建议从 GitHub网页下载二进制轮。
您可以下载此 二进制轮, 它针对Windows Python 2.7 64位安装。
您所需要做的就是:
  • 按下 Windows+R 组合键打开 Windows 命令行界面,或者在 cmd 中运行
  • 使用 cd 命令进入你下载 whl 文件的目录
  • 运行命令 pip install zbar-0.10-cp27-none-win_amd64.whl

例如,命令可以是:

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

如果您安装了多个Python版本,请确保使用正确的pip程序。
对于需要编译的任何包,您都可以使用一些代码来完成此操作。

1
zbar-0.10-cp27-none-win_amd64.whl不支持此平台。这是我遇到的错误。我正在努力在我的Win 7,64位Python 2.7中安装zbar。请帮忙。 - Shashank Singh
请查看 python --version 的输出,它不应该是64位的2.7版本。它可能是32位的2.7版本。请下载相应的wheel文件。 - Guillaume Jacquenot
1
只有一个选项可支持Python3,可用的是zbar-0.10-cp27-none-win_amd64.whl。 - vijayky88

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接