修复 Ubuntu 18.04 删除 Python 3.6 后的问题

修复 Ubuntu 18.04 删除 Python 3.6 后的问题

我想升级我的 Python 版本,当通过 apt 进行更新没有任何效果时,我决定构建最新版本的 Python 2 (2.7.16) 和 3 (3.7.2)。然而,在执行此操作之前,我不幸地决定删除我拥有的两个版本 (2.7.15~rc1-1、3.6.7),因此我基本上毁了我的系统。我可以顺利地构建和安装新版本,但当我重新启动时,GUI 无法加载。引导加载程序仍在运行,我可以进入终端。但是,当我尝试按照这里的一些建议操作时(例如安装 ubuntu-desktop),我发现我无法连接到互联网(当我尝试安装软件包时无法解析主机名,并且无法 ping www.google.com)。我尝试使用启用网络的恢复模式,但没有任何变化。

我有机会修复我的系统吗?或者我是否可以使用 Ubuntu 安装 USB 棒将系统重置为“出厂设置”(与以前相同的分区等),即使我必须删除上面的所有内容?我正在双启动上运行 Windows 10 和 Ubuntu 18.04,尽管第一次安装过程非常顺利,但我之前在笔记本电脑上双启动 Windows 和 Ubuntu 时遇到了问题,现在我担心我会造成更大的损害。如果有人能帮助我,我会非常高兴。

编辑#1:看来我仍然python3.6-minimal安装了,apt list --installed | grep 'python'输出:

libpython-stdlib/bionic,now 2.7.15~rc1-1 amd64 [installed,auto-removable]
libpython2.7/bionic-updates,bionic-security,now 2.7.15~rc1-1ubuntu0.1 amd64 [installed]
libpython2.7-minimal/bionic-updates,bionic-security,now 2.7.15~rc1-1ubuntu0.1 amd64 [installed]
libpython2.7-stdlib/bionic-updates,bionic-security,now 2.7.15~rc1-1ubuntu0.1 amd64 [installed]
libpython3-stdlib/bionic-updates,now 3.6.7-1~18.04 amd64 [installed]
libpython3.6/bionic-updates,now 3.6.7-1~18.04 amd64 [installed]
libpython3.6-minimal/bionic-updates,now 3.6.7-1~18.04 amd64 [installed]
libpython3.6-stdlib/bionic-updates,now 3.6.7-1~18.04 amd64 [installed]
python-apt-common/bionic-updates,bionic-updates,now 1.6.3ubuntu1 all [installed]
python-minimal/bionic,now 2.7.15~rc1-1 amd64 [installed,auto-removable]
python-talloc/bionic,now 2.1.10-2ubuntu1 amd64 [installed]
python2.7/bionic-updates,bionic-security,now 2.7.15~rc1-1ubuntu0.1 amd64 [installed]
python2.7-minimal/bionic-updates,bionic-security,now 2.7.15~rc1-1ubuntu0.1 amd64 [installed,automatic]
python3-minimal/bionic-updates,now 3.6.7-1~18.04 amd64 [installed]
python3.6/bionic-updates,now 3.6.7-1~18.04 amd64 [installed]
python3.6-minimal/bionic-updates,now 3.6.7-1~18.04 amd64 [installed]

还给ls /var/cache/apt/archive | grep 'python'我:

python3-apt_1.6.3ubuntu1_amd64.deb
python3-distupgrade_1%3a18.04.30_all.deb
python3-gi_3.26.1-2ubuntu1_amd64.deb
python3-gi-cairo_3.26.1-2ubuntu1_amd64.deb
python3-update-manager_1%3a18.04.11.9_all.deb
python-apt-common_1.6.3ubuntu1_all.deb

我希望这有帮助。

编辑#2:会话日志来自/var/log/apt/term.log

Log started: 2019-03-13  23:31:26
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 180782 files and directories currently installed.)
Removing gnome-software-plugin-snap (3.28.1-0ubuntu4.18.04.8) ...
Removing snapd (2.37.1.1+18.04) ...
Removing apparmor (2.12-4ubuntu5.1) ...
Removing apport-gtk (2.20.9-0ubuntu7.5) ...
Removing apport (2.20.9-0ubuntu7.5) ...
Removing ubuntu-desktop (1.417) ...
Removing gnome-control-center (1:3.28.2-0ubuntu0.18.04.2) ...
Removing language-selector-gnome (0.188.1) ...
Removing nautilus-share (0.7.3-2ubuntu3) ...
Removing apturl (0.5.2ubuntu14.2) ...
Removing apturl-common (0.5.2ubuntu14.2) ...
Removing command-not-found (18.04.5) ...
Removing firefox (65.0.1+build2-0ubuntu0.18.04.1) ...
Removing foomatic-db-compressed-ppds (20180306-1) ...
Removing gdm3 (3.28.3-0ubuntu18.04.4) ...
Removing gedit (3.28.1-1ubuntu1.1) ...
Removing gedit-common (3.28.1-1ubuntu1.1) ...
Removing ubuntu-session (3.28.1-0ubuntu3) ...
Removing update-notifier (3.192.1.5) ...
Removing update-manager (1:18.04.11.9) ...
Removing ubuntu-release-upgrader-gtk (1:18.04.30) ...
[1mdpkg:[0m aptdaemon: dependency problems, but removing anyway as you requested:
 python3-aptdaemon depends on aptdaemon.

Removing aptdaemon (1.1.1+bzr982-0ubuntu19) ...
[1mdpkg:[0m python3-aptdaemon: dependency problems, but removing anyway as you requested:
 python3-aptdaemon.gtk3widgets depends on python3-aptdaemon (= 1.1.1+bzr982-0ubuntu19).

Removing python3-aptdaemon (1.1.1+bzr982-0ubuntu19) ...
Selecting previously unselected package policykit-1-gnome.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 178575 files and directories currently installed.)
Preparing to unpack .../policykit-1-gnome_0.105-6ubuntu2_amd64.deb ...
Unpacking policykit-1-gnome (0.105-6ubuntu2) ...
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 178584 files and directories currently installed.)
Removing ibus-table (1.9.14-3) ...
Removing ibus (1.5.17-3ubuntu4) ...
Removing gnome-menus (3.13.3-11ubuntu1.1) ...
Removing gnome-online-accounts (3.28.0-0ubuntu2.1) ...
Removing ubuntu-software (3.28.1-0ubuntu4.18.04.8) ...
Removing gnome-software (3.28.1-0ubuntu4.18.04.8) ...
Removing nautilus-extension-gnome-terminal (3.28.2-1ubuntu1~18.04.1) ...
Removing xorg (1:7.7+19ubuntu7.1) ...
Removing gnome-terminal (3.28.2-1ubuntu1~18.04.1) ...
Removing printer-driver-postscript-hp (3.17.10+repack0-5) ...
Removing hplip (3.17.10+repack0-5) ...
Removing hplip-data (3.17.10+repack0-5) ...
[1mdpkg:[0m [1;33mwarning:[0m while removing hplip-data, directory '/usr/share/hplip/ui5' not empty so not removed
[1mdpkg:[0m [1;33mwarning:[0m while removing hplip-data, directory '/usr/share/hplip/scan' not empty so not removed
[1mdpkg:[0m [1;33mwarning:[0m while removing hplip-data, directory '/usr/share/hplip/prnt' not empty so not removed
[1mdpkg:[0m [1;33mwarning:[0m while removing hplip-data, directory '/usr/share/hplip/pcard' not empty so not removed
[1mdpkg:[0m [1;33mwarning:[0m while removing hplip-data, directory '/usr/share/hplip/installer' not empty so not removed
[1mdpkg:[0m [1;33mwarning:[0m while removing hplip-data, directory '/usr/share/hplip/fax' not empty so not removed
[1mdpkg:[0m [1;33mwarning:[0m while removing hplip-data, directory '/usr/share/hplip/copier' not empty so not removed
[1mdpkg:[0m [1;33mwarning:[0m while removing hplip-data, directory '/usr/share/hplip/base/pexpect' not empty so not removed
Removing ubuntu-standard (1.417) ...
Removing language-selector-common (0.188.1) ...
Removing xserver-xorg (1:7.7+19ubuntu7.1) ...
Removing python3-apport (2.20.9-0ubuntu7.5) ...
Removing update-notifier-common (3.192.1.5) ...
Removing update-manager-core (1:18.04.11.9) ...
[1mdpkg:[0m [1;33mwarning:[0m while removing update-manager-core, directory '/var/lib/update-manager' not empty so not removed
Removing ubuntu-minimal (1.417) ...
Removing nplan (0.40.1~18.04.4) ...
Removing netplan.io (0.40.1~18.04.4) ...
[1mdpkg:[0m [1;33mwarning:[0m while removing netplan.io, directory '/etc/netplan' not empty so not removed
Removing networkd-dispatcher (1.7-0ubuntu3.3) ...
Removing openprinting-ppds (20180306-1) ...
Removing orca (3.28.0-3ubuntu1) ...
Removing plymouth-theme-ubuntu-text (0.9.3-1ubuntu7.18.04.1) ...
update-initramfs: deferring update (trigger activated)
Removing printer-driver-foo2zjs (20170320dfsg0-4) ...
Removing printer-driver-foo2zjs-common (20170320dfsg0-4) ...
Removing printer-driver-m2300w (0.51-13) ...
Removing printer-driver-ptouch (1.4.2-3) ...
Removing printer-driver-pxljr (1.4+repack0-5) ...
Removing unattended-upgrades (1.1ubuntu1.18.04.9) ...
Removing python3-problem-report (2.20.9-0ubuntu7.5) ...
Removing ubuntu-web-launchers (18.04.6) ...
Removing ubuntu-release-upgrader-core (1:18.04.30) ...
Removing software-properties-gtk (0.96.24.32.7) ...
Removing ubuntu-drivers-common (1:0.5.2.2) ...
Removing python3-aptdaemon.gtk3widgets (1.1.1+bzr982-0ubuntu19) ...
Removing python3-launchpadlib (1.10.6-1) ...
Removing python3-keyring (10.6.0-1) ...
Removing python3-secretstorage (2.3.1-2) ...
Removing python3-cryptography (2.1.4-1ubuntu1.2) ...
Removing python3-asn1crypto (0.24.0-1) ...
Removing python3-brlapi (5.5-4ubuntu2.0.1) ...
Removing python3-gi-cairo (3.26.1-2ubuntu1) ...
Removing system-config-printer (1.5.11-1ubuntu2) ...
Removing system-config-printer-common (1.5.11-1ubuntu2) ...
Removing python3-cairo:amd64 (1.16.2-1) ...
Removing python3-macaroonbakery (1.1.3-1) ...
Removing python3-requests-unixsocket (0.1.5-3) ...
Removing python3-pymacaroons (0.13.0-1) ...
Removing python3-nacl (1.1.2-1build1) ...
Removing python3-cffi-backend (1.11.5-1) ...
Removing usb-creator-gtk (0.3.5) ...
Removing usb-creator-common (0.3.5) ...
Removing python3-debian (0.1.32) ...
Removing python3-commandnotfound (18.04.5) ...
Removing python3-keyrings.alt (3.0-1) ...
Removing python3-crypto (2.6.1-8ubuntu2) ...
Removing system-config-printer-udev (1.5.11-1ubuntu2) ...
Removing python3-cupshelpers (1.5.11-1ubuntu2) ...
Removing software-properties-common (0.96.24.32.7) ...
Removing python3-debconf (1.5.66) ...
Removing python3-defer (1.0.6-2build1) ...
Removing python3-distro-info (0.18) ...
Removing python3-gdbm:amd64 (3.6.7-1~18.04) ...
Removing totem-plugins (3.26.0-0ubuntu6.2) ...
Removing python3-lazr.restfulclient (0.13.5-1) ...
Removing python3-httplib2 (0.9.2+dfsg-1) ...
Removing python3-wadllib (1.3.2-3ubuntu0.18.04.1) ...
Removing python3-lazr.uri (1.0.3-2build1) ...
Removing python3-louis (3.5.0-1ubuntu0.3) ...
Removing rhythmbox-plugins (3.4.2-4ubuntu1) ...
Removing python3-mako (1.0.7+ds1-1) ...
Removing python3-markupsafe (1.0-1build1) ...
Removing python3-netifaces (0.10.4-0.1build4) ...
Removing python3-oauth (1.0.1-5) ...
Removing python3-olefile (0.45.1-1) ...
Removing python3-pexpect (4.2.1-1) ...
Removing python3-reportlab (3.4.0-3build1) ...
Removing python3-pil:amd64 (5.1.0-1) ...
Removing python3-zope.interface (4.3.2-1build2) ...
Removing python3-protobuf (3.0.0-9.1ubuntu1) ...
Removing python3-ptyprocess (0.5.2-1) ...
Removing python3-pyatspi (2.26.0+dfsg-1) ...
Removing python3-renderpm:amd64 (3.4.0-3build1) ...
Removing python3-reportlab-accel:amd64 (3.4.0-3build1) ...
Removing python3-rfc3339 (1.0-4) ...
Removing python3-simplejson (3.13.2-1) ...
Removing python3-software-properties (0.96.24.32.7) ...
Removing python3-speechd (0.8.8-1ubuntu1) ...
Removing python3-systemd (234-1build1) ...
Removing python3-tz (2018.3-2) ...
Removing python3-uno (1:6.0.7-0ubuntu0.18.04.2) ...
Removing python3-xdg (0.25-4ubuntu1) ...
Removing python3-xkit (0.5.0ubuntu2) ...
Removing python3-yaml (3.12-1build2) ...
Removing rhythmbox-plugin-alternative-toolbar (0.18.0-1) ...
Removing ubuntu-system-service (0.3.1) ...
Removing ufw (0.35-5) ...
Skip stopping firewall: ufw (not enabled)
Removing python3-requests (2.18.4-2ubuntu0.1) ...
Removing python3-certifi (2018.1.18-2) ...
Removing python3-chardet (3.0.4-1) ...
Removing python3-cups (1.9.73-2) ...
Removing python3-dbus (1.2.6-1) ...
Removing python3-gi (3.26.1-2ubuntu1) ...
Removing python3-idna (2.6-1) ...
Removing python3-pkg-resources (39.0.1-2) ...
Removing python3-urllib3 (1.22-1) ...
Removing python3-six (1.11.0-2) ...
Removing python3-distupgrade (1:18.04.30) ...
Removing python3-update-manager (1:18.04.11.9) ...
Removing lsb-release (9.20170808ubuntu1) ...
Removing python3-apt (1.6.3ubuntu1) ...
[1mdpkg:[0m gir1.2-ibus-1.0:amd64: dependency problems, but removing anyway as you requested:
 gnome-shell depends on gir1.2-ibus-1.0 (>= 1.5.2); however:
  Package gir1.2-ibus-1.0:amd64 is to be removed.

Removing gir1.2-ibus-1.0:amd64 (1.5.17-3ubuntu4) ...
[1mdpkg:[0m python3: dependency problems, but removing anyway as you requested:
 gnome-shell depends on python3; however:
  Package python3 is to be removed.

Removing python3 (3.6.7-1~18.04) ...
[1mdpkg:[0m gnome-shell: dependency problems, but removing anyway as you requested:
 network-manager-gnome depends on policykit-1-gnome | polkit-1-auth-agent; however:
  Package policykit-1-gnome is not configured yet.
  Package polkit-1-auth-agent is not installed.
  Package policykit-1-gnome which provides polkit-1-auth-agent is not configured yet.
  Package gnome-shell which provides polkit-1-auth-agent is to be removed.

Removing gnome-shell (3.28.3-0ubuntu0.18.04.4) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for libreoffice-common (1:6.0.7-0ubuntu0.18.04.2) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for libglib2.0-0:amd64 (2.56.3-0ubuntu0.18.04.1) ...
Processing triggers for cups (2.2.7-1ubuntu2.3) ...
Processing triggers for initramfs-tools (0.130ubuntu3.7) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-46-generic
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up policykit-1-gnome (0.105-6ubuntu2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for shared-mime-info (1.9-2) ...
Processing triggers for dbus (1.12.2-1ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Log ended: 2019-03-13  23:32:0

我现在可以看到很多非常重要的软件包被删除了。从我的 bash 历史记录来看,似乎我在构建新版本之前就调用了这两个sudo apt remove python软件包sudo apt remove python3。我修改了原来的问题以反映这一点。

答案1

我按照建议重新安装 Ubuntu 解决了这个问题(谢谢!)。

我第一次安装 Ubuntu 时,严格遵循了在不同的硬盘上双启动 Windows 10 和 Linux Ubuntu [重复]

我仍然有 USB 安装介质,因此我从它启动,选择“其他”,然后只需进行三处更改(Ubuntu 安装在分区 /dev/sdd 上):

  • 将 sdd2 设置为 ext4 文件系统(而不是“不使用此分区”),并将“/”设置为挂载
  • 将 sdd4 设置为 ext4 文件系统(而不是“不使用此分区”),并将“/home”设置为挂载
  • 在下拉列表中设置 sdd1 用于引导加载程序

所以总而言之,我只需要重新执行我初始安装时使用的部分设置,而不必先创建分区表等。我确保没有在任何地方选择“格式化分区”选项,因此当安装完成后,我的所有文件都还在那里。谢谢大家的帮助!

相关内容