Zbar 安装错误

Zbar 安装错误

之前已经安装过了,但这个错误又出现了

sudo apt-get install libzbar-dev

安装 Zbar 时出现此错误

pip3 install zbar

错误

   Building wheel for zbar (setup.py) ... error
      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-07_tun3x/zbar_ee181338cecb48f9bdc1dbc37504ffdd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-07_tun3x/zbar_ee181338cecb48f9bdc1dbc37504ffdd/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-d6wmsk5m
           cwd: /tmp/pip-install-07_tun3x/zbar_ee181338cecb48f9bdc1dbc37504ffdd/
      Complete output (55 lines):
      running bdist_wheel
      running build
      running build_ext
      building 'zbar' extension
      creating build
      creating build/temp.linux-x86_64-3.8
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c zbarmodule.c -o build/temp.linux-x86_64-3.8/zbarmodule.o
      In file included from zbarmodule.c:24:
      zbarmodule.h:42:5: error: unknown type name ‘PyIntObject’
         42 |     PyIntObject val;            /* integer value is super type */
            |     ^~~~~~~~~~~
      zbarmodule.c: In function ‘version’:
      zbarmodule.c:66:5: error: too few arguments to function ‘zbar_version’
         66 |     zbar_version(&major, &minor);
            |     ^~~~~~~~~~~~
      In file included from zbarmodule.h:26,
                       from zbarmodule.c:24:
      /usr/include/zbar.h:269:12: note: declared here
        269 | extern int zbar_version(unsigned *major,
            |            ^~~~~~~~~~~~
      zbarmodule.c: In function ‘initzbar’:
      zbarmodule.c:112:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
        112 |         return;
            |         ^~~~~~
      zbarmodule.c:106:1: note: declared here
        106 | initzbar (void)
            | ^~~~~~~~
      zbarmodule.c:115:34: error: ‘PyInt_Type’ undeclared (first use in this function); did you mean ‘PySet_Type’?
        115 |     zbarEnumItem_Type.tp_base = &PyInt_Type;
            |                                  ^~~~~~~~~~
            |                                  PySet_Type
      zbarmodule.c:115:34: note: each undeclared identifier is reported only once for each function it appears in
      zbarmodule.c:129:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
        129 |         return;
            |         ^~~~~~
      zbarmodule.c:106:1: note: declared here
        106 | initzbar (void)
            | ^~~~~~~~
      zbarmodule.c:137:13: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
        137 |             return;
            |             ^~~~~~
      zbarmodule.c:106:1: note: declared here
        106 | initzbar (void)
            | ^~~~~~~~
      zbarmodule.c:146:21: warning: implicit declaration of function ‘Py_InitModule’ [-Wimplicit-function-declaration]
        146 |     PyObject *mod = Py_InitModule("zbar", zbar_functions);
            |                     ^~~~~~~~~~~~~
      zbarmodule.c:146:21: warning: initialization of ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
      zbarmodule.c:148:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
        148 |         return;
            |         ^~~~~~
      zbarmodule.c:106:1: note: declared here
        106 | initzbar (void)
            | ^~~~~~~~
      error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
      ----------------------------------------
      ERROR: Failed building wheel for zbar
      Running setup.py clean for zbar
    Successfully built pypng qrtools
    Failed to build zbar
    Installing collected packages: zbar, qrtools, pypng
        Running setup.py install for zbar ... error
        ERROR: Command errored out with exit status 1:
         command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-07_tun3x/zbar_ee181338cecb48f9bdc1dbc37504ffdd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-07_tun3x/zbar_ee181338cecb48f9bdc1dbc37504ffdd/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-188bdnav/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/zbar
             cwd: /tmp/pip-install-07_tun3x/zbar_ee181338cecb48f9bdc1dbc37504ffdd/
        Complete output (55 lines):
        running install
        running build
        running build_ext
        building 'zbar' extension
        creating build
        creating build/temp.linux-x86_64-3.8
        x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c zbarmodule.c -o build/temp.linux-x86_64-3.8/zbarmodule.o
        In file included from zbarmodule.c:24:
        zbarmodule.h:42:5: error: unknown type name ‘PyIntObject’
           42 |     PyIntObject val;            /* integer value is super type */
              |     ^~~~~~~~~~~
        zbarmodule.c: In function ‘version’:
        zbarmodule.c:66:5: error: too few arguments to function ‘zbar_version’
           66 |     zbar_version(&major, &minor);
              |     ^~~~~~~~~~~~
        In file included from zbarmodule.h:26,
                         from zbarmodule.c:24:
        /usr/include/zbar.h:269:12: note: declared here
          269 | extern int zbar_version(unsigned *major,
              |            ^~~~~~~~~~~~
        zbarmodule.c: In function ‘initzbar’:
        zbarmodule.c:112:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
          112 |         return;
              |         ^~~~~~
        zbarmodule.c:106:1: note: declared here
          106 | initzbar (void)
              | ^~~~~~~~
        zbarmodule.c:115:34: error: ‘PyInt_Type’ undeclared (first use in this function); did you mean ‘PySet_Type’?
          115 |     zbarEnumItem_Type.tp_base = &PyInt_Type;
              |                                  ^~~~~~~~~~
              |                                  PySet_Type
        zbarmodule.c:115:34: note: each undeclared identifier is reported only once for each function it appears in
        zbarmodule.c:129:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
          129 |         return;
              |         ^~~~~~
        zbarmodule.c:106:1: note: declared here
          106 | initzbar (void)
              | ^~~~~~~~
        zbarmodule.c:137:13: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
          137 |             return;
              |             ^~~~~~
        zbarmodule.c:106:1: note: declared here
          106 | initzbar (void)
              | ^~~~~~~~
        zbarmodule.c:146:21: warning: implicit declaration of function ‘Py_InitModule’ [-Wimplicit-function-declaration]
          146 |     PyObject *mod = Py_InitModule("zbar", zbar_functions);
              |                     ^~~~~~~~~~~~~
        zbarmodule.c:146:21: warning: initialization of ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
        zbarmodule.c:148:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
          148 |         return;
              |         ^~~~~~
        zbarmodule.c:106:1: note: declared here
          106 | initzbar (void)
              | ^~~~~~~~
        error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-07_tun3x/zbar_ee181338cecb48f9bdc1dbc37504ffdd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-07_tun3x/zbar_ee181338cecb48f9bdc1dbc37504ffdd/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-188bdnav/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/zbar Check the logs for full command output.

答案1

尝试一下,对于 pyhon3

sudo apt install python3-zbar

对于 python2

sudo apt install python-zbar

答案2

或者,使用灯箱,zbar 的简单包装器。在 GitHub 上,最后一次提交来自 2020 年(zbar-py 为 2019 年),有 156 颗星(zbar-py 为 80 颗)。

相关内容