Installing seaborn on Docker Alpine

后端 未结 1 1826
礼貌的吻别
礼貌的吻别 2021-02-14 01:21

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         


        
1条回答
  •  不思量自难忘°
    2021-02-14 02:10

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

    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.

    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
    

    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/).

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

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

    0 讨论(0)
提交回复
热议问题