6

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?

Elderry
  • 1,902
  • 5
  • 31
  • 45

1 Answers1

5

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

Guillaume Jacquenot
  • 11,217
  • 6
  • 43
  • 49
  • 1
    zbar-0.10-cp27-none-win_amd64.whl is not a supported wheel on this platform. This is the error I am getting. I am trying hard to install zbar in my Win 7, 64bit Python 2.7. Kindly help. – Shashank Singh Sep 10 '18 at 10:04
  • Please look at the output of `python --version`, it should not be 2.7 with 64 bit. It could be 2.7 with 32 bit. Download the corresponding wheel – Guillaume Jacquenot Sep 10 '18 at 13:36
  • 1
    only 3 zbar-0.10-cp27-none-win_amd64.whl is available , on option to support python3 – vijayky88 Dec 06 '18 at 06:37