在Docker Alpine上安装seaborn

我正在尝试安装这个Dockerfile的seaborn:

 FROM alpine:latest RUN apk add --update python py-pip python-dev RUN pip install seaborn CMD python 

我得到的错误与numpyscipyscipy要求)有关。 它始于:

/tmp/easy_install-nvj61E/numpy-1.11.1/setup.py:327:UserWarning:无法识别的setuptools命令,继续生成Cython源代码并展开模板

并以…结束

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

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

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

命令'/ bin / sh -c pip install seaborn'返回一个非零的代码:1

任何想法如何我可以解决这个问题?

要解决这个错误,你需要安装gccapk install gcc

但是你会看到你会遇到新的错误,因为numpy,matplotlip和scipy有几个依赖关系。 您还需要安装gfortranmusl-devfreetype-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/ ) 。

我个人也必须安装电子证书,但似乎你没有这个问题。

注意 :你也可以从python:2.7-alpine图像中构build你的图像,以避免安装python和pip。