Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.1k views
in Technique[技术] by (71.8m points)

opencv - Failed building wheel for zbar in Raspberry Pi3

I wanna use the OpenCV and the camera module to recognize the qr code with Raspberry Pi3.

And I followed the article here, all the things are good until run "from pyzbar import pyzbar". It shows the following text:

    Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyzbar

I keep searching for the solution for this and I've runned the following instructions:

sudo apt-get install python-qrtools
sudo apt-get install libzbar-dev
sudo pip install zbar

but when I run the "sudo pip install zbar", it show this:

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting zbar
  Using cached https://files.pythonhosted.org/packages/33/54/cc5819efc9ee7e34b60b41e1d2d4753b6dd0c26a41c9a552611f66aa106e/zbar-0.10.tar.bz2
Building wheels for collected packages: zbar
  Running setup.py bdist_wheel for zbar ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2m99GE/zbar/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
', '
');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-THRXHm --python-tag cp27:
  running bdist_wheel
  running build
  running build_ext
  building 'zbar' extension
  creating build
  creating build/temp.linux-armv7l-2.7
  arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-InigCj/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c zbarmodule.c -o build/temp.linux-armv7l-2.7/zbarmodule.o
  zbarmodule.c: In function ‘version’:
  zbarmodule.c:66:5: error: too few arguments to function ‘zbar_version’
       zbar_version(&major, &minor);
       ^~~~~~~~~~~~
  In file included from zbarmodule.h:26,
                   from zbarmodule.c:24:
  /usr/include/zbar.h:269:12: note: declared here
   extern int zbar_version(unsigned *major,
              ^~~~~~~~~~~~
  error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for zbar
  Running setup.py clean for zbar
Failed to build zbar
Installing collected packages: zbar
  Running setup.py install for zbar ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2m99GE/zbar/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
', '
');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-ADZ1pW/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'zbar' extension
    creating build
    creating build/temp.linux-armv7l-2.7
    arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-InigCj/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c zbarmodule.c -o build/temp.linux-armv7l-2.7/zbarmodule.o
    zbarmodule.c: In function ‘version’:
    zbarmodule.c:66:5: error: too few arguments to function ‘zbar_version’
         zbar_version(&major, &minor);
         ^~~~~~~~~~~~
    In file included from zbarmodule.h:26,
                     from zbarmodule.c:24:
    /usr/include/zbar.h:269:12: note: declared here
     extern int zbar_version(unsigned *major,
                ^~~~~~~~~~~~
    error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2m99GE/zbar/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
', '
');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-ADZ1pW/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-2m99GE/zbar/

i think the error "Failed building wheel for zbar" will be the key of it, and i run the following instructions:

sudo apt install python-zbar
sudo apt install zbar-tools

after running, when i run "sudo pip install zbar", it still shows the same error. There's still no modules named pyzbar. Anyone know where the problem is?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...