尝试在docker容器中安装python时出现/ usr / bin / dpkg错误

时间:2020-01-02 16:23:56

标签: python docker ubuntu-18.04 apt apt-get

所以我正在使用Docker进行项目,并且需要安装Python。

以前,当我的基本容器为ubuntu:18.04时,此方法工作正常

包裹被这样包裹:

FROM ubuntu:18.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no- 
install-recommends \
    python \

...

我的项目还将包括Swift,因此我像这样更改了基本图像:

FROM swift:5.1

现在,当apt-get尝试安装python时,出现以下错误:

Errors were encountered while processing: /var/cache/apt/archives/python2.7-minimal_2.7.17-1~18.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

swift:5.1的Dockerfile可以在这里找到:

https://github.com/apple/swift-docker/blob/72177227fe1ed2da8e921ba291aeb3ff69591e1a/5.1/ubuntu/18.04/Dockerfile

这也是基于ubuntu:18.04,所以我认为问题一定是由该dockerfile中的某些东西引起的。

我最好的猜测是,也许是因为swift:5.1还安装了libpython2.7

此错误究竟是什么?如何避免该错误?

编辑:这是出现错误的上下文:

Selecting previously unselected package python2.7-minimal.
Preparing to unpack .../python2.7-minimal_2.7.17-1~18.04_amd64.deb ...
new installation of python2.7-minimal; /usr/lib/python2.7/site-packages is a directory
which is expected a symlink to /usr/local/lib/python2.7/dist-packages.
please find the package shipping files in /usr/lib/python2.7/site-packages and
file a bug report to ship these in /usr/lib/python2.7/dist-packages instead
aborting installation of python2.7-minimal
dpkg: error processing archive /var/cache/apt/archives/python2.7-minimal_2.7.17-1~18.04_amd64.deb (--unpack):
 new python2.7-minimal package pre-installation script subprocess returned error exit status 1
Selecting previously unselected package python-minimal.
Preparing to unpack .../python-minimal_2.7.15~rc1-1_amd64.deb ...
Unpacking python-minimal (2.7.15~rc1-1) ...
Selecting previously unselected package python2.7.
Preparing to unpack .../python2.7_2.7.17-1~18.04_amd64.deb ...
Unpacking python2.7 (2.7.17-1~18.04) ...
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack .../libpython-stdlib_2.7.15~rc1-1_amd64.deb ...
Unpacking libpython-stdlib:amd64 (2.7.15~rc1-1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/python2.7-minimal_2.7.17-1~18.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

0 个答案:

没有答案