简体   繁体   English

错误:在 alpine docker 映像上安装 pip 软件包时,命令“gcc”失败,退出状态为 1

[英]error: command 'gcc' failed with exit status 1 when installing pip packages on alpine docker image

I'm attempting transition my base docker image from centos 7 to alpine, however I receive gcc errors when trying to install pip packages.我正在尝试将我的基本 docker 映像从 centos 7 转换为 alpine,但是在尝试安装 Z62031C2A45DBCBBA28 软件包时收到 gcc 错误。

This is a snippet of the error received:这是收到的错误片段:

Successfully built backports.ssl-match-hostname configobj dpkt iniparse IPy kitchen logmatic-python maxminddb NeuroTools procfs pycparser python-json-logger pyudev repoze.lru scandir scapy
Failed to build guppy kiwisolver numpy psutil pygpgme pyliblzma python-ldap pyxattr subprocess32
Installing collected packages: atomicwrites, attrs, backports.functools-lru-cache, backports.ssl-match-hostname, certifi, chardet, six, configobj, configparser, contextlib2, cycler, decorator, dnspython, dpkt, urllib3, elasticsearch, elasticsearch5, elasticsearch6, funcsigs, ipaddress, maxminddb, idna, requests, geoip2, guppy, scandir, pathlib2, more-itertools, zipp, importlib-metadata, iniparse, IPy, kafka, kafka-python, kitchen, kiwisolver, python-json-logger, logmatic-python, mock, NeuroTools, numpy, pyparsing, packaging, pbr, ptyprocess, pexpect, pluggy, ply, procfs, psutil, py, pyasn1, pyasn1-modules, pycparser, pygpgme, pyliblzma, wcwidth, pytest, python-dateutil, python-ldap, pytz, pyudev, pyxattr, redis, repoze.lru, scapy, subprocess32, xmltodict
    Running setup.py install for guppy: started
    Running setup.py install for guppy: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-PWr6Cn/guppy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-PWr6Cn/guppy/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-ogmKgm/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-PWr6Cn/guppy/
    Complete output (117 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/guppy
    copying guppy/__init__.py -> build/lib.linux-x86_64-2.7/guppy
    creating build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/docexample.py -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/test_heapyc.py -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/__init__.py -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/test_guppy.py -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/test_heapy.py -> build/lib.linux-x86_64-2.7/guppy/doc
    creating build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/Code.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/Cat.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/IterPermute.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/OutputHandling.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/KnuthBendix.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/KanExtension.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/Unpack.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/__init__.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/FSA.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/tkcursors.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/cmd.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/xterm.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/etc.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/ExecfileWithModuleInfo.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/Help.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/RE.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/RE_Rect.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/Glue.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/textView.py -> build/lib.linux-x86_64-2.7/guppy/etc
    copying guppy/etc/Compat.py -> build/lib.linux-x86_64-2.7/guppy/etc
    creating build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Html.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Latex.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/DottedTree.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Main.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/FileIO.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Filer.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/__init__.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/XHTML.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Text.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Document.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Gsml.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Help.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Exceptions.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/Tester.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    copying guppy/gsl/SpecNodes.py -> build/lib.linux-x86_64-2.7/guppy/gsl
    creating build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Spec.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/OutputHandling.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Remote.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/RefPat.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/ImpSet.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Monitor.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Classifiers.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/__init__.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/RM.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/UniSet.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/View.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Target.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Doc.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Prof.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Part.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Console.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Use.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/Path.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/AbstractAlgebra.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/RemoteConstants.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    copying guppy/heapy/pbhelp.py -> build/lib.linux-x86_64-2.7/guppy/heapy
    creating build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_Classifiers.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_sf.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_heapyc.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_OutputHandling.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_Spec.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/__init__.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_View.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_Path.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_UniSet.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_menuleak.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_dependencies.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_RetaGraph.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_Part.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_all.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_RefPat.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/test_ER.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    copying guppy/heapy/test/support.py -> build/lib.linux-x86_64-2.7/guppy/heapy/test
    creating build/lib.linux-x86_64-2.7/guppy/sets
    copying guppy/sets/test.py -> build/lib.linux-x86_64-2.7/guppy/sets
    copying guppy/sets/__init__.py -> build/lib.linux-x86_64-2.7/guppy/sets
    copying guppy/doc/gsl.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/heapy_UniSet.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/sets.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/heapyc.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/guppy.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/ProfileBrowser.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/heapy_tutorial.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/index.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/docexample.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/heapy_Use.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/gslexample.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/heapy_RootState.html -> build/lib.linux-x86_64-2.7/guppy/doc
    copying guppy/doc/pbscreen.jpg -> build/lib.linux-x86_64-2.7/guppy/doc
    running build_ext
    building 'guppy.sets.setsc' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    creating build/temp.linux-x86_64-2.7/src/sets
    gcc -fno-strict-aliasing -Os -fomit-frame-pointer -g -DNDEBUG -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/python2.7 -c src/sets/sets.c -o build/temp.linux-x86_64-2.7/src/sets/sets.o
    src/sets/sets.c:33:10: fatal error: Python.h: No such file or directory
     #include "Python.h"
              ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-PWr6Cn/guppy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-PWr6Cn/guppy/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-ogmKgm/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
The command '/bin/sh -c pip install -r /home/admin/container_files/requirements.txt' returned a non-zero code: 1

I can only derive that gcc is not being installed (correctly?) despite being listed in my Dockerfile below.尽管在下面的 Dockerfile 中列出,但我只能得出 gcc 没有安装(正确吗?)。 I've also attempted to run it within its own level in case that would install it correctly:我还尝试在它自己的级别内运行它,以防它正确安装:

FROM alpine:latest

RUN apk update && apk upgrade
RUN apk add --no-cache bash\
                       python \
                       pkgconfig \
                       git \
                       gcc \
                       openldap \
                       libcurl \
    && rm -rf /var/cache/apk/*
RUN wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py

ADD requirements.txt /home/admin/container_files/
RUN pip install setuptools==30.1.0
RUN pip install -r /home/admin/container_files/requirements.txt

Uncommenting the pip install -r requirements.txt line results in the image being built.取消注释pip install -r requirements.txt行会导致构建映像。 After ssh'ing into an instance of the image, gcc does appear to be installed, however I'm unsure why it would then error above:在 ssh 进入图像实例后,gcc 似乎已安装,但是我不确定为什么它会在上面出错:

$ docker run -it alpine-image bash
bash-5.0# gcc --version
gcc (Alpine 8.3.0) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

While in the docker container I can try pip installing a dependency on its own, however this gives a similar error as above:在 docker 容器中,我可以尝试 pip 自行安装依赖项,但这会产生与上述类似的错误:

bash-5.0# pip install pygpgme
Collecting pygpgme
  Using cached https://files.pythonhosted.org/packages/dc/96/b2bcbd3a216af313bb9045c2e573aa18653876a65db471b86be7598234dd/pygpgme-0.3.tar.gz
Building wheels for collected packages: pygpgme
  Building wheel for pygpgme (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ih85iq/pygpgme/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ih85iq/pygpgme/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-1HBTfc --python-tag cp27
       cwd: /tmp/pip-install-ih85iq/pygpgme/
  Complete output (18 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/gpgme
  copying gpgme/__init__.py -> build/lib.linux-x86_64-2.7/gpgme
  copying gpgme/editutil.py -> build/lib.linux-x86_64-2.7/gpgme
  running build_ext
  building 'gpgme._gpgme' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/src
  gcc -fno-strict-aliasing -Os -fomit-frame-pointer -g -DNDEBUG -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/python2.7 -c src/gpgme.c -o build/temp.linux-x86_64-2.7/src/gpgme.o
  src/gpgme.c:21:10: fatal error: Python.h: No such file or directory
   #include <Python.h>
            ^~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pygpgme
  Running setup.py clean for pygpgme
Failed to build pygpgme
Installing collected packages: pygpgme
    Running setup.py install for pygpgme ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ih85iq/pygpgme/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ih85iq/pygpgme/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-1HWn3q/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-ih85iq/pygpgme/
    Complete output (18 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/gpgme
    copying gpgme/__init__.py -> build/lib.linux-x86_64-2.7/gpgme
    copying gpgme/editutil.py -> build/lib.linux-x86_64-2.7/gpgme
    running build_ext
    building 'gpgme._gpgme' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    gcc -fno-strict-aliasing -Os -fomit-frame-pointer -g -DNDEBUG -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/python2.7 -c src/gpgme.c -o build/temp.linux-x86_64-2.7/src/gpgme.o
    src/gpgme.c:21:10: fatal error: Python.h: No such file or directory
     #include <Python.h>
              ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ih85iq/pygpgme/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ih85iq/pygpgme/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-1HWn3q/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

I'd like to understand why gcc is behaving in this way, and if there is a better way to transition to an alpine image from centos?我想了解为什么 gcc 会以这种方式运行,以及是否有更好的方法可以从 centos 过渡到高山图像?

Additional information:附加信息:
Alpine version: 3.10.3高山版本:3.10.3
python version: 2.7.16 python 版本:2.7.16
pip version: 19.3.1 pip 版本:19.3.1

Missing the header file Python.h , this file is provide by python2-dev ( -dev mean package for doing development with ).缺少 header 文件Python.h ,此文件由python2-dev提供( -dev表示 package 用于进行开发)。

With this https://pkgs.alpinelinux.org/contents you can search all packages that have Python.h使用此https://pkgs.alpinelinux.org/contents您可以搜索所有具有Python.h的软件包

I was able to run pip install pygpgme by adding these 3 packages:通过添加以下 3 个包,我能够运行pip install pygpgme

  • python2-dev python2-dev
  • gpgme-dev gpgme-开发
  • libc-dev libc开发

And the Dockerfile will be: Dockerfile将是:

FROM alpine:latest

RUN apk update && apk upgrade
RUN apk add --no-cache bash\
                       python \
                       pkgconfig \
                       git \
                       gcc \
                       openldap \
                       libcurl \
                       python2-dev \
                       gpgme-dev \
                       libc-dev \
    && rm -rf /var/cache/apk/*
RUN wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py
RUN pip install setuptools==30.1.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Alpine 编译失败中的 Gdal 安装 - “错误:命令 &#39;gcc&#39; 失败,退出状态为 1” - Gdal installation in Alpine compilation failure - "error: command 'gcc' failed with exit status 1" FFvideo-&gt;错误:命令“ gcc”失败,退出状态为1 - FFvideo -> error: command 'gcc' failed with exit status 1 docker 中的 Python 错误 - distutils.errors.CompileError:命令“gcc”失败,退出状态为 1 - Python error in docker - distutils.errors.CompileError: command 'gcc' failed with exit status 1 apk python 软件包未安装在 Alpine Docker 图像中 - apk python packages not installing in Alpine Docker Image 无法在 docker 中安装 pyodbc 并获取错误命令“gcc”失败,退出状态为 1 - Cannot install pyodbc in docker and getting error command 'gcc' failed with exit status 1 尝试使用 PyPy docker 映像安装 Mecab 时出现“'gcc' failed with exit status 1” - Getting “'gcc' failed with exit status 1” when trying to install Mecab with PyPy docker image 在docker alpine上安装软件包时的约束无法满足 - Unsatisfiable constraints when installing packages on docker alpine gcc&#39;失败,退出状态-Python docker集成错误 - gcc' failed with exit status - Python docker integration error 错误:在 Alpine Docker 映像上安装 PostGIS 时无法满足约束 - ERROR: unsatisfiable constraints when installing PostGIS on the Alpine Docker image 在alpine中安装python3软件包时出错 - Error when installing python3 packages in alpine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM