带有python&的Docker映像由于缺少编译器错误而导致高山故障 [英] Docker image with python & alpine failure due missing compiler error

查看:136
本文介绍了带有python&的Docker映像由于缺少编译器错误而导致高山故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找同时具有python3和crontab的docker映像。
当我使用 python:latest 作为基础时,我没有cron,但是安装了所有必需的python程序包都没有问题。

I'm looking for a docker image with both python3 and a crontab. When I use python:latest as a base, I have no cron, but all required python packages install without problem.

当我使用alpine作为基础时,我的(busybox)cron工作正常,但由于编译器错误而无法安装特定的python软件包。

When I use alpine as a base I have the (busybox) cron working, but are unable to install specific python package due to compiler error.

当我使用 python:alpine 时也是如此。

Collecting pynacl>=1.0.1 (from paramiko->-r required_python_packages.txt (line 6))
  Downloading PyNaCl-1.1.2.tar.gz (3.1MB)
    Complete output from command python setup.py egg_info:

        No working compiler found, or bogus compiler options
        passed to the compiler from Python's distutils module.
        See the error messages above.

有没有建议?

推荐答案

您需要一个可运行的编译器,解决此问题的最简单方法是像这样安装build-base软件包:

You need a working compiler, the easiest way around this is to install the build-base package like so:

apk add --no-cache --virtual .pynacl_deps build-base python3-dev libffi-dev

这将安装编译pynacl所需的各种工具,并且 pip install pynacl 现在将成功。

This will install various tools that are required to compile pynacl and pip install pynacl will now succeed.

请注意,使用-virtual 标志是可选的,但是它可以轻松修剪图像,因为您可以运行 apk del .pynacl_deps 稍后在您的Dockerfile中使用,因为不再需要它们了,这会减小映像的整体大小。

Note it is optional to use the --virtual flag but it makes it easy to trim the image because you can run apk del .pynacl_deps later in your Dockerfile as they are not needed any more and would reduce the overall size of the image.

这篇关于带有python&的Docker映像由于缺少编译器错误而导致高山故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆