在Docker Alpine上安装Seaborn [英] Installing seaborn on Docker Alpine

查看:122
本文介绍了在Docker Alpine上安装Seaborn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to install seaborn with this Dockerfile:

FROM alpine:latest

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

RUN pip install seaborn

CMD python

我得到的错误与numpyscipy(seaborn要求)有关.它开始于:

The error I get is related to numpy and scipy (required by seaborn). It starts with:

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

/tmp/easy_install-nvj61E/numpy-1.11.1/setup.py:327: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates

get_mathlib_info中的文件"numpy/core/setup.py",第654行

File "numpy/core/setup.py", line 654, in get_mathlib_info

RuntimeError:断开的工具链:无法链接简单的C程序

RuntimeError: Broken toolchain: cannot link a simple C program

命令"python setup.py egg_info";失败,错误代码为/tmp/pip-build-DZ4cXr/scipy/

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-DZ4cXr/scipy/

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

The command '/bin/sh -c pip install seaborn' returned a non-zero code: 1

有什么主意我可以解决这个问题吗?

Any idea how I can fix this?

推荐答案

要解决此错误,您需要安装gcc:apk add gcc.

To fix this error, you need to install gcc: apk add gcc.

但是您会看到您将遇到一个新错误,因为numpy,matplotlip和scipy具有多个依赖关系.您还需要安装gfortranmusl-devfreetype-dev等.

But you will see that you will hit a new error as numpy, matplotlip and scipy have several dependencies. You need to also install gfortran, musl-dev, freetype-dev, etc.

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

Here is a Dockerfile based on you initial one that will install those dependencies as well as 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删除依赖项以限制图像的大小(

You'll notice that I'm removing the dependencies using apk-del .build-deps to limit the size of your image (http://www.sandtable.com/reduce-docker-image-sizes-using-alpine/).

我个人也必须安装ca证书,但是看来您没有这个问题.

Personally I also had to install ca-certificates but it seems you didn't have this issue.

注意:您也可以从python:2.7-alpine映像构建映像,以避免自己安装python和pip.

Note: You could also build your image FROM the python:2.7-alpine image to avoid installing python and pip yourself.

这篇关于在Docker Alpine上安装Seaborn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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