我按照以下说明在我的 Ubuntu 16.04 机器上安装 Python3.6这里在此过程中,我还sudo apt-get purge
对一些 Python3.5 包做了一些操作(这样我就可以只保留 3.6 的东西)。查看我的历史记录,我发现我做了如下操作:
sudo apt-get purge python3
sudo apt autoremove
sudo apt-get purge python3.5
sudo apt-get purge python3.5-minimal
sudo apt-get purge python3-minimal
sudo apt-get purge libpython3-stdlib
sudo apt-get purge libpython3.5
sudo apt-get purge libpython3.5-minimal
sudo apt-get purge libpython3.5-stdlib
sudo apt-get --purge autoremove
我也安装了python3-pip
。
上述破坏的最终结果(奇怪地)弄乱了我的终端外观。下面您可以看到左侧的旧终端外观(该终端在上述命令之前启动)和新外观(右侧):
该终端的新外观存在一些问题:
- 没有垂直滚动条(左侧窗口获得焦点时自动显示滚动条)
- 没有菜单栏
- 不同的背景颜色
- 不同的字体和字体大小
- 在终端窗口中单击鼠标右键不允许我访问终端的配置文件(没有弹出菜单出现)。
我随后再次安装已删除的软件包,但这并没有解决我的问题。
我最初根本无法启动任何新终端。一旦我这样做了,sudo apt-get purge gnome-terminal
我又能够启动新终端(但上面显示的外观不正确)。如果我安装,gnome-terminal
我又失去了启动新终端窗口的能力。所以我认为我失去了启动新终端的能力,gnome-terminal
而且我创建的所有新终端窗口都是xterm
终端。
我怎样才能恢复我的终端外观?
答案1
我做了以下事情:
mkdir ~/repair_python
cd ~/repair_python
apt-get download python2.7-minimal libpython2.7-minimal python-minimal python2.7
sudo dpkg -i --force-all *.deb
…正如建议的那样这个答案。不知为何,这恢复了我的终端外观。现在,如果我尝试:
sudo apt-get install python3
我得到以下信息:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3 is already the newest version (3.5.1-3).
0 upgraded, 0 newly installed, 0 to remove and 241 not upgraded.
4 not fully installed or removed.
Need to get 0 B/8,710 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
No apport report written because the error message indicates its
a followup error from a previous failure.
dpkg: error processing package python3 (--configure): package is in a very bad
inconsistent state; you should reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of click:
click depends on python3:any (>= 3.2~); however: Package python3 is not configured yet.
dpkg: error processing package click (--configure):
dependency problems - leaving unconfigured dpkg:
dependency problems prevent configuration of gnome-menus:
gnome-menus depends on python3:any (>=3.1~); however:
Package python3 is not configured yet.
dpkg: error processing package gnome-menus (--configure): dependency problems
- leaving unconfigured dpkg:
dependency problems prevent configuration of python3-packagekit:
python3-packagekit depends on python3:any (>= 3.3.2-2~);
however:
Package python3 is not configured yet.
dpkg: error processing package python3-packagekit (--configure):
dependency problems - leaving unconfigured
No apport report written
because the error message indicates its a followup error from a previous failure.
No apport report written because MaxReports is reached already
Errors were encountered while processing: python3 click gnome-menus
python3-packagekit E: Sub-process /usr/bin/dpkg returned an error code (1)
...所以很明显我的 Python 3 仍然有些问题(尽管我可以从终端启动 Python 3 REPL)但至少我的终端现在看起来很正常。
答案2
您成功搞砸了您的系统。切勿删除或者以其他方式破坏Ubuntu 预装的版本python
!python3
许多重要的系统组件都需要其中一个才能工作。
现在尝试再次修复问题:
看来你的包管理器apt
仍然有效,所以去看看/var/log/apt/history.log
。此日志文件包含最近执行的所有包管理操作。检查在你的过程中删除了哪些包(包括所有因为依赖 Python 而被自动删除的包)并将它们添加回来。
以此方式撤消所有删除后,您的系统应该恢复到原来状态。