【问题标题】:python install zbar error: Setup script exited with error: command 'gcc' failed with exit status 1python install zbar错误:安装脚本退出并出现错误:命令'gcc'失败,退出状态为1
【发布时间】:2019-02-04 06:08:58
【问题描述】:

环境:

pyenv versions
system
2.7.13
* 3.4.3 (set by /home/foo/.pyenv/version)
3.4.3/envs/venv343
venv343

easy_install zbar 时遇到以下错误:

Searching for zbar
Reading https://pypi.python.org/simple/zbar/
Downloading https://files.pythonhosted.org/packages/e0/5c/bd2a96a9f2adacffceb4482cdd56831735ab5a67ea6a60c0a8757c17b62e/zbar-0.10.tar.gz#sha256=5d0dad77dbca8822a4689c546f598f28030321efb14fa36ac
5e409d181a0d9dd
Best match: zbar 0.10
Processing zbar-0.10.tar.gz
Writing /tmp/easy_install-oaUXl5/zbar-0.10/setup.cfg
Running zbar-0.10/setup.py -q bdist_egg --dist-dir /tmp/easy_install-oaUXl5/zbar-0.10/egg-dist-tmp-5Jv6UI
In file included from zbarmodule.c:24:0:
zbarmodule.h:26:18: fatal error: zbar.h: No such file or directory
 #include <zbar.h>
                  ^
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1

正如在 stackoverflow 上提到的这个问题,以下程序已经尝试但不起作用:

sudo apt-get install build-essential
sudo apt-get install bzip2
sudo apt-get install bzip2-dev
sudo apt-get install gcc
sudo apt-get install gcc-4.4
sudo apt-get install libbz2
sudo apt-get install libbz2-dev
sudo apt-get install libevent
sudo apt-get install libevent1-dev
sudo apt-get install libevent-dev
sudo apt-get install libgcc
sudo apt-get install libgcc1
sudo apt-get install libgcc1-4.7-dev
sudo apt-get install libgcc1-dev
sudo apt-get install libgcc-4.8-dev
sudo apt-get install libpython3.4-dev
sudo apt-get install libpython3.4-stdlib
sudo apt-get install libpython3-dev
sudo apt-get install libpython3-stdlib
sudo apt-get install libssl-dev
sudo apt-get install openssl
sudo apt-get install python3.4-dev
sudo apt-get install python3.4-devel
sudo apt-get install python3-dev
sudo apt-get install python3-devl
sudo apt-get install python3-gcc
sudo apt-get install python-dev
sudo apt-get install python-devel
sudo apt-get install python-setuptools

虽然按照一些朋友的建议安装 libzbar-dev,但错误信息似乎有所不同但仍然无法正常工作

Searching for zbar
Reading https://pypi.python.org/simple/zbar/
Best match: zbar 0.10
Downloading https://files.pythonhosted.org/packages/e0/5c/bd2a96a9f2adacffceb4482cdd56831735ab5a67ea6a60c0a8757c17b62e/zbar-0.10.tar.gz#sha256=5d0dad77dbca8822a4689c546f598f28030321efb14fa36ac
5e409d181a0d9dd
Processing zbar-0.10.tar.gz
Writing /tmp/easy_install-cw6n9lyu/zbar-0.10/setup.cfg
Running zbar-0.10/setup.py -q bdist_egg --dist-dir /tmp/easy_install-cw6n9lyu/zbar-0.10/egg-dist-tmp-vbl6ojsc
In file included from zbarmodule.c:24:0:
zbarmodule.h:42:5: error: unknown type name ‘PyIntObject’
     PyIntObject val;            /* integer value is super type */
     ^
zbarmodule.c: In function ‘initzbar’:
zbarmodule.c:112:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
         return;
         ^
zbarmodule.c:115:34: error: ‘PyInt_Type’ undeclared (first use in this function)
     zbarEnumItem_Type.tp_base = &PyInt_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]
         return;
         ^
zbarmodule.c:137:13: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
             return;
             ^
zbarmodule.c:146:5: warning: implicit declaration of function ‘Py_InitModule’ [-Wimplicit-function-declaration]
     PyObject *mod = Py_InitModule("zbar", zbar_functions);
     ^
zbarmodule.c:146:21: warning: initialization makes pointer from integer without a cast [enabled by default]
     PyObject *mod = Py_InitModule("zbar", zbar_functions);
                     ^
zbarmodule.c:148:9: warning: ‘return’ with no value, in function returning non-void [-Wreturn-type]
         return;
         ^
error: Setup script exited with error: command 'gcc' failed with exit status 1

我该如何解决这个问题?谢谢大家的回答

【问题讨论】:

  • 尝试安装libzbar-dev。
  • 仍然不起作用,但错误信息似乎不同:(
  • 你用的是什么版本的python?乍一看,您似乎正在尝试在 3.x 上安装,但该模块仅支持 2.x。
  • Python 3.4.3 和 pyenv 1.1.1-5-g7467eec。也安装了 2.7.13。

标签: python zbar


【解决方案1】:

在 ubuntu 和 Mint 上

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

pip install libzbar-cffi==0.2.1

【讨论】:

    【解决方案2】:

    zbar_version 函数需要一个补丁参数。尝试构建您自己的模块:https://github.com/rxwen/zbar.git

    pip install git+https://github.com/rxwen/zbar.git

    【讨论】:

      【解决方案3】:

      从另一个帖子似乎无关紧要,我想出了解决方案

      ImportError: No module named zbar on Linux Mint

      然而只有 zbar-tools 不足以获得好的结果,我把

      sudo apt-get install zbar-

      然后按TAB然后找到zbar-dbg,试了一下,确实有效。

      sudo apt-get install zbar-tools zbar-dbg

      当 gcc 错误确实由 zbar 问题引起时,我真的很震惊。 也许对类似问题有一些启发,所以我把它放在这里。

      【讨论】:

        猜你喜欢
        • 2011-06-10
        • 2023-03-14
        • 1970-01-01
        • 2014-11-21
        • 2015-07-17
        • 2014-10-29
        • 1970-01-01
        • 2013-11-23
        相关资源
        最近更新 更多