在Docker镜像中安装python-sympy

3

我正在尝试在基于Debian的Docker镜像中使用Dockerfile安装Sympy:

FROM  debian:jessie
RUN apt-get update && apt-get install -y \
    python \
    build-essential \
    make \
    gcc \
    pandoc \
    lrslib \
    dos2unix \
    python-dev \
    python-pygments \
    python-numpy \
    python-pip 

RUN  apt-get -y install python-sympy
....

在第二个RUN命令中,APT工具告诉我它将不得不下载900 MB(!)的依赖项,其中大部分是字体。这根本没有任何意义,因为Sympy是一个纯Python软件包。

然后我尝试了标准设置:

....
COPY    sympy-0.7.6.tar.gz /sympy-0.7.6.tar.gz
RUN     tar -xzvf /sympy-0.7.6.tar.gz
WORKDIR /sympy-0.7.6
RUN     python setup.py install

这个有效,但在运行的容器中,Sympy返回字符串格式化错误,而我在自己的Linux安装中没有看到。感谢任何提示。


我猜漂亮打印功能是字体发挥作用的地方。 - Mike
1个回答

8
我猜这900MB不是依赖项,而是建议。
$ apt-cache show python-sympy
Package: python-sympy
Priority: optional
Section: universe/python
Installed-Size: 14889
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Georges Khaznadar <georgesk@debian.org>
Architecture: all
Source: sympy
Version: 0.7.4.1-1
Depends: python (>= 2.7), python (<< 2.8), python:any (>= 2.7.1-0ubuntu2)
Recommends: python-imaging, python-ctypes, ipython, python-numpy, texlive-fonts-extra, dvipng
Filename: pool/universe/s/sympy/python-sympy_0.7.4.1-1_all.deb
Size: 2826308
MD5sum: 4bfdb84df0e626f13b46b0d44517a492
SHA1: bcc0a9b24d6f974d3ece4b770fc607f25a9e61f6
SHA256: 3c490be9ab494a37ff4a5f5729f1de261546391acc5377a4b48c40cbee0657fa
Description-en: Computer Algebra System (CAS) in Python
 SymPy is a Python library for symbolic mathematics (manipulation). It aims to
 become a full-featured computer algebra system (CAS) while keeping the code as
 simple as possible in order to be comprehensible and easily extensible. SymPy
 is written entirely in Python and does not require any external libraries,
 except optionally for plotting support.
Description-md5: 6056e6cef6dcfe0106530b41d92b60d5
Homepage: https://github.com/sympy/sympy
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu

您可以使用--no-install-recommends选项来省略建议,因此可以在Dockerfile中使用它:

FROM  debian:jessie
RUN apt-get update && apt-get install -y \
    python \
    build-essential \
    make \
    gcc \
    pandoc \
    lrslib \
    dos2unix \
    python-dev \
    python-pygments \
    python-numpy \
    python-pip 

RUN  apt-get -y --no-install-recommends install python-sympy

快速简单的回答。谢谢。Sympy现在可以无错误运行。 - MortCanty

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接