在 Docker 图像中安装 python-sympy

Installing python-sympy in a Docker image

我正在尝试使用 Docker 文件在基于 Debian 的 Docker 映像中安装 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
....

在第二个 运行 命令中,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 returns 字符串格式错误,我在自己的 Linux 安装中没有看到。感谢任何提示。

我猜那 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