我试图使用Dockerfile在基于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
....
在第二个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安装中看不到的字符串格式错误.感谢任何提示.
解决方法:
我猜那些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-recommended选项省略建议,因此可以在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