Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to install zbar with pip on Windows

Tags:

python

pip

zbar

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?

like image 912
Elderry Avatar asked Apr 01 '17 06:04

Elderry


People also ask

Why is pip install not working windows?

The Pip Install is Not in the System VariableFor Python commands to run from a Windows Command Prompt, the path of your pip install will need to be added to your PATH system variable. It should be added automatically if you installed Python via the installation file.

Why is pip install not working in Python?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.


1 Answers

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

like image 102
Guillaume Jacquenot Avatar answered Oct 23 '22 05:10

Guillaume Jacquenot