意外 apt-get remove 后如何恢复 python

How to restore after accidentally apt-get remove python

是的。我已经做到了。太蠢了。

我不知道它会自带它的依赖项,只想从头开始安装 python 2 和 3(因为这个问题:https://askubuntu.com/questions/897355/how-to-change-default-idle-for-python)。

现在,我仍然可以使用我的终端,检查了这些答案:

https://askubuntu.com/questions/741265/apt-get-remove-python-150mb-apt-get-install-python-687kb

https://askubuntu.com/questions/437644/i-accidentaly-did-sudo-apt-get-remove-python

但是在 运行 sudo apt-get install ubuntu-desktop 之后我得到了这些错误:

Setting up python-ldb (2:1.1.24-1ubuntu3) ...
/var/lib/dpkg/info/python-ldb.postinst: 6: /var/lib/dpkg/info/python-ldb.postinst: pycompile: not found
dpkg: error processing package python-ldb (--configure):
 subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
                                                              Setting up python-tdb (1.3.8-2) ...
/var/lib/dpkg/info/python-tdb.postinst: 6: /var/lib/dpkg/info/python-tdb.postinst: pycompile: not found
dpkg: error processing package python-tdb (--configure):
 subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of python-samba:
 python-samba depends on python-crypto; however:
  Package python-crypto is not configured yet.
 python-samba depends on python-ldb (>= 1.1.2~); however:
  Package python-ldb is not configured yet.
 python-samba depends on python-tdb; however:
  Package python-tdb is not configured yet.

dpkg: error processing package python-samba (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Processing triggers for libc-bin (2.23-0ubuntu7) ...

Errors were encountered while processing:
 mercurial-common
 python-crypto
 python-dnspython
 python-ldb
 python-tdb
 python-samba
E: Sub-process /usr/bin/dpkg returned an error code (1)

每个 apt-get 安装命令都会抛出这个。

有没有办法恢复这些依赖关系?

https://askubuntu.com/questions/187227/i-run-sudo-apt-get-remove-python2-7-can-i-restore-my-ubuntu-now

To do this, manually download the python2.7 package (and its dependencies), and manually install them using dpkg (bypassing APT, which requires Python). Once that's installed, apt should work again, and so apt-get install ubuntu-desktop will restore your system. (If apt-get still doesn't work, you might also need to download and install any missing dependencies.)

这个有用吗?

(dpkg) - https://help.ubuntu.com/lts/serverguide/dpkg.html

哈利路亚。

sudo apt-get install --reinstall python python-chardet python-colorama python-distlib python-django python-django-tables2 python-six python-html5lib python-lxml python-minimal python-pkg-resources python-setuptools python-urllib3 python-requests python-pip python-virtualenv

sudo apt-get install --reinstall python-dnspython

sudo apt autoremove

sudo apt-get -f install

在 Internet 最深处探索了一整天后,这些命令对我有用。

python-dnspython 并且在第一个命令后 samba 仍然丢失,--reinstall python-dnspython 也将 samba 拉了进来。 Autoremove 删除了不必要的依赖项。

当然,其中一些可能是多余的,但我只是到处关注一些遗失已久的论坛帖子,重要的是它有效。

您可以通过 运行

再次恢复所有内容

sudo apt install gnome

即使您离开时仅使用内核

我执行了以下操作并能够完全恢复我的系统:

1) sudo apt-get update

2) 运行 上面由 MattSom 给出的 4 个命令(感谢他):

sudo apt-get install --reinstall python python-chardet python-colorama python-distlib python-django python-django-tables2 python-six python-html5lib python-lxml python-minimal python-pkg-resources python-setuptools python-urllib3 python-requests python-pip python-virtualenv

sudo apt-get install --reinstall python-dnspython

sudo apt autoremove

sudo apt-get -f install

但是 GUI 仍然不可用。我在下面 运行 也恢复了它:

3) sudo apt-get install --reinstall ubuntu-desktop

对我来说这个

sudo apt-get install --reinstall python3 python3-chardet python3-colorama python3-distlib python3-django python3-django-tables2 python3-six python3-html5lib python3-lxml python3-minimal python3-pkg-resources python3-setuptools python3-urllib3 python3-requests python3-pip python3-virtualenv

sudo apt-get install --reinstall python-dnspython // this was needed 

sudo apt autoremove // there was nothing to autoremove

sudo apt-get -f install // there was nothing dependences. 

还不够。 我必须先 运行 这一行,因为我的互联网连接中断了

sudo dhclient -r;sudo dhclient

然后 运行 前一个块然后这个

sudo apt-get install ubuntu-minimal ubuntu-desktop

在这之后我不得不重新安装我的 NVIDIA 驱动程序。