Failed to install zbar with pip on Windows

2019-02-25 04:03发布

I'm trying to install zbar on my Windows x64 machine:

pip install zbar

And this is what I got:

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\

Anyone knows how to fix this problem?

标签: python pip zbar
1条回答
甜甜的少女心
2楼-- · 2019-02-25 04:35

You are trying to install zbar package with pip. When doing so, pip downloads the source and tries to compile the C/C++ source code of this project.

To do such a thing, you need a C/C++ compiler and having all dependencies. It may be complicated to have pip compiles this package.

The other solution is to download a binary wheel that embeds all binaries. zbar developers propose to download a binary wheel from their GitHub webpage

You can download this binary wheel, that targets a Windows Python 2.7 64 bit installation.

All you have to do is:

  • open a Windows cli with Windows+R and by running inside cmd
  • go to the directory where you have downloaded the whl file, with cd instructions
  • run pip install zbar-0.10-cp27-none-win_amd64.whl

For example, the command can be

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

If you have several Python installations, make sure to use the correct pip program.

You can do it for any package with some code that has to be compiled

查看更多
登录 后发表回答