在 ubuntu 18.04 上卸载 Python 2.7.12 导致软件包损坏

在 ubuntu 18.04 上卸载 Python 2.7.12 导致软件包损坏

我犯了一个可怕的错误,因为我删除了我的 ubuntu 机器 18.04 的 pyth 2.7,因为我只想保留 python3,但不幸的是有一些组件是使用 python 2.7 中的 pip 安装的(例如 ansible)。

现在,当我尝试重新安装 python 时出现以下错误:

:~$ sudo apt install python
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python : PreDepends: python-minimal (= 2.7.12-1~16.04) but it is not going to be installed
          Depends: python2.7 (>= 2.7.12-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

当我检查残留配置时,我看到了以下内容:

:~$ apt list | grep residual-config

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

ansible/xenial-updates,xenial-updates,xenial-security,xenial-security 2.0.0.2-2ubuntu1.3 all [residual-config]
aspell-en/xenial,xenial 7.1-0-1.1 all [residual-config]
docker/xenial,now 1.5-1 amd64 [residual-config]
docker.io/xenial-updates 18.09.7-0ubuntu1~16.04.7 amd64 [residual-config]
initscripts/xenial,now 2.88dsf-59.3ubuntu2 amd64 [residual-config]
insserv/xenial,now 1.14.0-5ubuntu3 amd64 [residual-config]
libgdbm3/xenial,now 1.8.3-13.1 amd64 [residual-config]
libiscsi2/xenial,now 1.12.0-2 amd64 [residual-config]
libjson-c2/xenial-updates,xenial-security 0.11-4ubuntu2.6 amd64 [residual-config]
libperl5.22/xenial-updates,xenial-security 5.22.1-9ubuntu0.9 amd64 [residual-config]
libpython3.5-minimal/xenial-updates,xenial-security 3.5.2-2ubuntu0~16.04.13 amd64 [residual-config]
libserf-1-1/xenial,now 1.3.8-1 amd64 [residual-config]
libtxc-dxtn-s2tc0/xenial,now 0~git20131104-1.1 amd64 [residual-config]
libunistring0/xenial,now 0.9.3-5.2ubuntu1 amd64 [residual-config]
libustr-1.0-1/xenial,now 1.0.4-5 amd64 [residual-config]
libv8-3.14.5/xenial,now 3.14.5.8-5ubuntu2 amd64 [residual-config]
libxml-sax-perl/xenial,xenial,now 0.99+dfsg-2ubuntu1 all [residual-config]
linux-image-4.4.0-112-generic/xenial-updates,xenial-security,now 4.4.0-112.135 amd64 [residual-config]
linux-image-4.4.0-124-generic/xenial-updates,xenial-security,now 4.4.0-124.148 amd64 [residual-config]
linux-image-4.4.0-148-generic/xenial-updates,xenial-security,now 4.4.0-148.174 amd64 [residual-config]
linux-image-4.4.0-93-generic/xenial-updates,xenial-security,now 4.4.0-93.116 amd64 [residual-config]
linux-image-extra-4.4.0-112-generic/xenial-updates,xenial-security,now 4.4.0-112.135 amd64 [residual-config]
linux-image-extra-4.4.0-124-generic/xenial-updates,xenial-security,now 4.4.0-124.148 amd64 [residual-config]
linux-image-extra-4.4.0-93-generic/xenial-updates,xenial-security,now 4.4.0-93.116 amd64 [residual-config]
linux-modules-4.4.0-148-generic/xenial-updates,xenial-security,now 4.4.0-148.174 amd64 [residual-config]
linux-modules-extra-4.4.0-148-generic/xenial-updates,xenial-security,now 4.4.0-148.174 amd64 [residual-config]
lua-lpeg/xenial-updates 0.12.2-1ubuntu1 amd64 [residual-config]
lxc-common/xenial-updates,now 2.0.11-0ubuntu1~16.04.3 amd64 [residual-config]
mariadb-client-10.0/xenial-updates,xenial-security,now 10.0.38-0ubuntu0.16.04.1 amd64 [residual-config]
mariadb-common/xenial-updates,xenial-updates,xenial-security,xenial-security,now 10.0.38-0ubuntu0.16.04.1 all [residual-config]
monitoring-plugins-basic/xenial,now 2.1.2-2ubuntu2 amd64 [residual-config]
mysql-server-5.7/xenial-updates,xenial-security 5.7.33-0ubuntu0.16.04.1 amd64 [residual-config]
nginx-common/xenial-updates,xenial-updates,xenial-security,xenial-security 1.10.3-0ubuntu0.16.04.5 all [residual-config]
ntp/xenial-updates,xenial-security 1:4.2.8p4+dfsg-3ubuntu5.10 amd64 [residual-config]
ntpdate/xenial-updates,xenial-security 1:4.2.8p4+dfsg-3ubuntu5.10 amd64 [residual-config]
openjdk-8-jre-headless/xenial-updates,xenial-security 8u282-b08-0ubuntu1~16.04 amd64 [residual-config]
php-pear/bionic,bionic 1:1.10.8+submodules+notgz-1+ubuntu18.04.1+deb.sury.org+1 all [residual-config]
php7.0-curl/bionic 7.0.33-29+ubuntu18.04.1+deb.sury.org+1 amd64 [residual-config]
php7.0-gd/bionic 7.0.33-29+ubuntu18.04.1+deb.sury.org+1 amd64 [residual-config]
php7.0-ldap/bionic 7.0.33-29+ubuntu18.04.1+deb.sury.org+1 amd64 [residual-config]
php7.0-mysql/bionic 7.0.33-29+ubuntu18.04.1+deb.sury.org+1 amd64 [residual-config]
php7.0-xmlrpc/bionic 7.0.33-29+ubuntu18.04.1+deb.sury.org+1 amd64 [residual-config]
python/xenial-updates 2.7.12-1~16.04 amd64 [residual-config]
python3.5-minimal/xenial-updates,xenial-security 3.5.2-2ubuntu0~16.04.13 amd64 [residual-config]
resolvconf/xenial-updates,xenial-updates 1.78ubuntu7 all [residual-config]
subversion/xenial-updates,xenial-security 1.9.3-2ubuntu1.3 amd64 [residual-config]
sysv-rc/xenial,xenial,now 2.88dsf-59.3ubuntu2 all [residual-config]
xterm/xenial-updates,xenial-security 322-1ubuntu1.2 amd64 [residual-config]

当我使用 dpkg 检查保留的包时,什么也没有出现:

~$ dpkg --get-selections | grep hold

我的操作系统版本是:

~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"

我知道我造成了损害,并且我吃过苦头才学到这个教训,现在重新安装 python 2.7.12 的适当方法是什么?

任何帮助、提示或建议都将不胜感激。

答案1

我升级了整个操作系统,现在一切都正常了,谢谢你的帮助和时间

相关内容