Ubuntu 16.04 中 Python 软件包的 apt-get 升级错误

Ubuntu 16.04 中 Python 软件包的 apt-get 升级错误
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libpython3.6 : Depends: libpython3.6-stdlib (= 3.6.5-5~16.04.york1) but 3.6.5-5~16.04.york0 is installed
 libpython3.6-dev : Depends: libpython3.6-stdlib (= 3.6.5-5~16.04.york1) but 3.6.5-5~16.04.york0 is installed
 libpython3.6-stdlib : Depends: libpython3.6-minimal (= 3.6.5-5~16.04.york0) but 3.6.5-5~16.04.york1 is installed
 python3.6 : Depends: libpython3.6-stdlib (= 3.6.5-5~16.04.york1) but 3.6.5-5~16.04.york0 is installed
E: Unmet dependencies. Try using -f.

我已经在 Ubuntu 16.04 中使用 PPA JonathanF 进行了安装,并且它一直运行良好,直到今天遇到这个问题。

TI 尝试并得到以下错误:

$ sudo apt-get upgrade -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libpython3.6-stdlib
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
Need to get 0 B/1,989 kB of archives.
After this operation, 1,393 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 231399 files and directories currently installed.)
Preparing to unpack .../libpython3.6-stdlib_3.6.5-5~16.04.york1_amd64.deb ...
Unpacking libpython3.6-stdlib:amd64 (3.6.5-5~16.04.york1) over (3.6.5-5~16.04.york0) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.6-stdlib_3.6.5-5~16.04.york1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.6/lib2to3/refactor.py', which is also in package python3-lib2to3 3.6.5-3~16.04.york0.2
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libpython3.6-stdlib_3.6.5-5~16.04.york1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

这个答案对我有用=)

sudo dpkg --install --force all /var/cache/apt/archives/libpython3.6-stdlib_3.6.5-5~16.04.york1_amd64.deb

从:https://stackoverflow.com/a/50408787/1503549

注意:请记住随后执行以下操作:

sudo apt install -f

将“apt”替换为“apt-get”/“aptitude”,或您正在使用的任何 apt 衍生产品。

答案2

您的软件包似乎部分已过期。更新软件包列表,然后使用可用升级程序升级已安装的软件包,应该可以修复损坏的依赖项:

sudo apt-get update
sudo apt-get upgrade -f

如果没有的话,你能否编辑您的问题包括完整、逐字上述命令的输出是什么?谢谢。

答案3

你可能从多个地方安装了 Python 3.6,这导致了此问题(http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu例如)。

如果是这种情况,您需要从 /etc/apt/sources 中注释或删除它,执行 apt 更新,然后再次尝试 apt-get -f install。

相关内容