【问题标题】:How can I fix gcc error when install multidict in alpine docker container?在 alpine docker 容器中安装 multidict 时如何修复 gcc 错误?
【发布时间】:2020-04-19 16:33:27
【问题描述】:

问: 在我的 docker 容器中,我使用预先安装 gcc 的 apline linux 系统

apk 信息:

bash-4.4# apk info
....
gcc

但是当我安装 multidict 时,由于 gcc 错误而失败

bash-4.4# pip install multidict
Collecting multidict
  Using cached https://files.pythonhosted.org/packages/84/96/5503ba866d8d216e49a6ce3bcb288df8a5fb3ac8a90b8fcff9ddcda32568/multidict-4.7.3.tar.gz
Building wheels for collected packages: multidict
  Building wheel for multidict (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-79jceuft/multidict/setup.py'"'"'; __file__='"'"'/tmp/pip-install-79jceuft/multidict/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-57k4lw21 --python-tag cp37
       cwd: /tmp/pip-install-79jceuft/multidict/
 ....
    /usr/local/include/python3.7m/Python.h:11:20: fatal error: limits.h: No such file or directory
     #include <limits.h>
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-79jceuft/multidict/setup.py'"'"'; __file__='"'"'/tmp/pip-install-79jceuft/multidict/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-lomj_vmk/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

我该如何解决这个问题?

【问题讨论】:

  • this answer 有帮助吗?
  • 我已经修复了
  • 安装 musl-dev

标签: python gcc alpine


【解决方案1】:

简单的解决方法是在 dockerfile 中添加以下命令:

RUN apk --no-cache add gcc musl-dev

感谢@Zosionlee 的提示。

【讨论】:

    【解决方案2】:

    预安装 gcc 和其他环境。

    例如

    RUN apk update \
        && apk add --no-cache gcc git python3-dev musl-dev linux-headers  
        libc-dev  rsync zsh \
        findutils wget util-linux grep libxml2-dev libxslt-dev \
        &&  pip3 install --upgrade pip
    

    【讨论】:

      【解决方案3】:

      遇到这个问题,是什么解决了我的问题而无需在系统上安装sudo

      $ pip install --upgrade pip setuptools-scm
      

      我也在虚拟环境中这样做了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-17
        • 2017-07-14
        • 2016-06-11
        • 1970-01-01
        • 2020-10-17
        • 2017-04-11
        • 1970-01-01
        • 2019-10-19
        相关资源
        最近更新 更多