简体   繁体   English

由于 gcc 错误,Python docker 映像构建失败

[英]Python docker image build fails due to gcc error

I am studying Nornir and want to containerize my application, here is the Dockerfile content:我正在研究Nornir并想将我的应用程序容器化,这里是 Dockerfile 内容:

FROM alpine

RUN apk update && apk upgrade 
RUN apk add gcc && apk add py3-pip && apk add libevent-dev
RUN apk add python3-dev && pip3 install nornir 

When I build the container with the command:当我使用命令构建容器时:

docker build --network=host .

I get the following errors:我收到以下错误:

somaiia@main-srv:~/core/nornir$ docker build --no-cache --network=host .
Sending build context to Docker daemon  10.24kB
Step 1/4 : FROM alpine
...
Step 4/4 : RUN apk add python3-dev && pip3 install nornir
 ---> Running in 025aee6693e4
(1/1) Installing python3-dev (3.9.7-r4)
Executing busybox-1.34.1-r5.trigger
OK: 229 MiB in 66 packages
Collecting nornir
  Downloading nornir-3.3.0-py3-none-any.whl (30 kB)
Collecting typing_extensions<5.0,>=4.1
  Downloading typing_extensions-4.2.0-py3-none-any.whl (24 kB)
Collecting importlib-metadata<5,>=4
  Downloading importlib_metadata-4.11.4-py3-none-any.whl (18 kB)
Collecting ruamel.yaml>=0.17
  Downloading ruamel.yaml-0.17.21-py3-none-any.whl (109 kB)
Collecting mypy_extensions<0.5.0,>=0.4.1
  Downloading mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
Collecting zipp>=0.5
  Downloading zipp-3.8.0-py3-none-any.whl (5.4 kB)
Collecting ruamel.yaml.clib>=0.2.6
  Downloading ruamel.yaml.clib-0.2.6.tar.gz (180 kB)
    **ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vs5bwupe/ruamel-yaml-clib_e6dc2477a7f349c6866be26f31b40c2e/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vs5bwupe/ruamel-yaml-clib_e6dc2477a7f349c6866be26f31b40c2e/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-jh_alwhp
         cwd: /tmp/pip-install-vs5bwupe/ruamel-yaml-clib_e6dc2477a7f349c6866be26f31b40c2e/
    Complete output (7 lines):
    /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory
    /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
    /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
    collect2: error: ld returned 1 exit status
    sys.argv ['/tmp/pip-install-vs5bwupe/ruamel-yaml-clib_e6dc2477a7f349c6866be26f31b40c2e/setup.py', 'egg_info', '--egg-base', '/tmp/pip-pip-egg-info-jh_alwhp']
    test compiling /tmp/tmp_ruamel_zq9s1x2j/test_ruamel_yaml.c -> test_ruamel_yaml link error /tmp/tmp_ruamel_zq9s1x2j/test_ruamel_yaml.c
    Exception: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/8b/25/08e5ad2431a028d0723ca5540b3af6a32f58f25e83c6dda4d0fcef7288a3/ruamel.yaml.clib-0.2.6.tar.gz#sha256=4ff604ce439abb20794f05613c374759ce10e3595d1867764dd1ae675b85acbd (from https://pypi.org/simple/ruamel-yaml-clib/) (requires-python:>=3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Collecting ruamel.yaml>=0.17
  Downloading ruamel.yaml-0.17.20-py3-none-any.whl (109 kB)
  Downloading ruamel.yaml-0.17.19-py3-none-any.whl (109 kB)
  Downloading ruamel.yaml-0.17.18-py3-none-any.whl (109 kB)
  Downloading ruamel.yaml-0.17.17-py3-none-any.whl (109 kB)
Collecting ruamel.yaml.clib>=0.1.2
  Downloading ruamel.yaml.clib-0.2.2.tar.gz (179 kB)
Using legacy 'setup.py install' for ruamel.yaml.clib, since package 'wheel' is not installed.
Installing collected packages: zipp, ruamel.yaml.clib, typing-extensions, ruamel.yaml, mypy-extensions, importlib-metadata, nornir
    Running setup.py install for ruamel.yaml.clib: started
    Running setup.py install for ruamel.yaml.clib: finished with status 'done'
Successfully installed importlib-metadata-4.11.4 mypy-extensions-0.4.3 nornir-3.3.0 ruamel.yaml-0.17.17 ruamel.yaml.clib-0.2.2 typing-extensions-4.2.0 zipp-3.8.0**

I am unable to build Nornir and can't proceed with the next steps as a result, what can I do?我无法构建 Nornir,因此无法继续下一步,我该怎么办?

In the logs the error originates from this在日志中,错误源于此

Collecting ruamel.yaml.clib>=0.2.6
  Downloading ruamel.yaml.clib-0.2.6.tar.gz (180 kB)
    **ERROR: Command errored out with exit status 1:

But following the logs we this但是按照我们的日志

Collecting ruamel.yaml.clib>=0.1.2
   Downloading ruamel.yaml.clib-0.2.2.tar.gz (179 kB)

Basically the first dependeny requirement demanded the ruamel.yaml.clib version to be greater or equal to 0.2.6 , but it failed.基本上第一个依赖要求要求ruamel.yaml.clib版本大于或等于0.2.6 ,但它失败了。

In the next try it tried for a version greater or equal to 0.1.2 .在下一次尝试中,它尝试了大于或等于0.1.2的版本。

In the final logs we see在我们看到的最终日志中

Successfully installed ... nornir-3.3.0 ruamel.yaml.clib-0.2.2 ...**

Meaning it successfully installed an older version of ruamel.yaml.clib library and finally installed the nornir library as well这意味着它成功安装了旧版本的ruamel.yaml.clib库,最后也安装了nornir

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

相关问题 由于 libGl 错误,无法运行 docker 镜像 - Unable to run docker image due to libGl error 由于 VS 构建工具,在 python 3.10 上安装 Hydra 失败 - Hydra install on python 3.10 fails due to VS build tools 无法为 python 代码构建 docker 映像 - Unable to build docker image for python code 我的python列表理解由于语法错误而失败 - My python list comprehension fails due to a syntax error 由于http连接错误,在anaconda中安装intel python失败 - Install intel python fails in anaconda due to http connection error 安装Python 3 Docker Ubuntu错误命令&#39;x86_64-linux-gnu-gcc - Installing Python 3 Docker Ubuntu error command 'x86_64-linux-gnu-gcc docker 中的 Python 错误 - distutils.errors.CompileError:命令“gcc”失败,退出状态为 1 - Python error in docker - distutils.errors.CompileError: command 'gcc' failed with exit status 1 错误greenlet docker build - Error greenlet docker build 由于 python 版本,Sam 构建失败 - Sam Build Failing due to python version Building docker image on Raspberry Pi 3B+ with python 3 and numpy, scipy, pillow and matplotlib fails - Building docker image on Raspberry Pi 3B+ with python 3 and numpy, scipy, pillow and matplotlib fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM