python2.7 在 xenial 上出现最小错误

python2.7 在 xenial 上出现最小错误

我正在尝试修复 Ubuntu 16.04 上的 python2.7 安装。我不断收到以下错误:

Fetched 1,440 kB in 0s (3,482 kB/s)
(Reading database ... 98454 files and directories currently installed.)
Preparing to unpack .../python2.7-minimal_2.7.12-1ubuntu0~16.04.1_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.12-1ubuntu0~16.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack .../libpython-stdlib_2.7.11-1_amd64.deb ...
Unpacking libpython-stdlib:amd64 (2.7.11-1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/python2.7-minimal_2.7.12-1ubuntu0~16.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我努力了

sudo apt 升级 sudo apt 更新

有人能帮帮我吗?谢谢。

更新:当我尝试 sudo apt -f install

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python python2.7-minimal
Suggested packages:
  python-doc python-tk binfmt-support
The following NEW packages will be installed:
  python python2.7-minimal
0 upgraded, 2 newly installed, 0 to remove and 150 not upgraded.
7 not fully installed or removed.
Need to get 0 B/1,432 kB of archives.
After this operation, 4,320 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 98458 files and directories currently installed.)
Preparing to unpack .../python2.7-minimal_2.7.12-1ubuntu0~16.04.1_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.12-1ubuntu0~16.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/python2.7-minimal_2.7.12-1ubuntu0~16.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

你能尝试跑步吗

mv /usr/lib/python2.7/site-packages /usr/lib/python2.7/dist-packages; ln -s dist-packages /usr/lib/python2.7/site-packages

这解决了我在 Docker 中遇到的类似问题。灵感来自https://forums.swift.org/t/lldb-install-precludes-installing-python-in-image/24040

相关内容