加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

numpy – 在Docker Alpine上安装seaborn

发布时间:2020-12-16 03:32:43 所属栏目:安全 来源:网络整理
导读:我试图用这个Dockerfile安装seaborn: FROM alpine:latestRUN apk add --update python py-pip python-dev RUN pip install seabornCMD python 我得到的错误与numpy和scipy有关(seaborn要求).它始于: /tmp/easy_install-nvj61E/numpy-1.11.1/setup.py:327:

我试图用这个Dockerfile安装seaborn:

FROM alpine:latest

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

RUN pip install seaborn

CMD python

我得到的错误与numpy和scipy有关(seaborn要求).它始于:

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

最后以

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

RuntimeError: Broken toolchain: cannot link a simple C program

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

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

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

要修复此错误,您需要安装gcc:apk install 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证书,但似乎你没有这个问题.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读