11

我正在尝试seaborn使用此 Dockerfile 进行安装:

FROM alpine:latest

RUN apk add --update python py-pip python-dev 

RUN pip install seaborn

CMD python

我得到的错误与numpyand相关scipy(需要seaborn)。它开始于:

/tmp/easy_install-nvj61E/numpy-1.11.1/setup.py:327:用户警告:无法识别 setuptools 命令,继续生成 Cython 源和扩展模板

并以

文件“numpy/core/setup.py”,第 654 行,在 get_mathlib_info

RuntimeError:损坏的工具链:无法链接简单的 C 程序

命令“python setup.py egg_info”在 /tmp/pip-build-DZ4cXr/scipy/ 中失败,错误代码为 1

命令“/bin/sh -c pip install seaborn”返回非零代码:1

知道如何解决这个问题吗?

4

1 回答 1

22

要修复此错误,您需要安装gcc: apk add gcc

但是你会看到你会遇到一个新的错误,因为 numpy、matplotlip 和 scipy 有几个依赖项。您还需要安装gfortran, musl-dev,freetype-dev等。

这是一个基于您初始文件的 Dockerfile,它将安装这些依赖项以及seaborn

FROM alpine:latest

# install dependencies
# the lapack package is only in the community repository
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk --update add --no-cache \ 
    lapack-dev \ 
    gcc \
    freetype-dev

RUN apk add python py-pip python-dev 

# Install dependencies
RUN apk add --no-cache --virtual .build-deps \
    gfortran \
    musl-dev \
    g++
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h

RUN pip install seaborn

# removing dependencies
RUN apk del .build-deps

CMD python

您会注意到我正在删除apk-del .build-deps用于限制图像大小的依赖项(http://www.sandtable.com/reduce-docker-image-sizes-using-alpine/)。

就个人而言,我还必须安装 ca-certificates 但似乎您没有这个问题。

注意:您还可以从python:2.7-alpine图像构建图像,以避免自己安装 python 和 pip。

于 2016-07-25T15:05:43.103 回答