2

I was following the instructions to install Python3.6 on my Ubuntu 16.04 machine from here and in the process I also did some sudo apt-get purge on some Python3.5 packages (so that I would only keep the 3.6 stuff). Looking at my history I see I did stuff like the following:

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

I also installed python3-pip.

The end result of the above depradations has (weirdly) messed up with my terminal appearence. Below you see my old terminal appearance to the left (that terminal was launched before the above commands) and the new appearance (to the right):

enter image description here

A number of things aren't right with the new appearence of the terminal:

  • no vertical scroll bar (the window to the left automatically shows a scroll bar when it receives focus)
  • no menu bar
  • different brackground color
  • diffrent font and font size
  • right mouse click in the terminal window does not allow me to access the terminal's profile (no pop-up menu appears).

I subsequently installed back again the packages I had removed but that didn't solve my problem.

I was initially unable to launch any new terminal at all. Once I did sudo apt-get purge gnome-terminal I was yet again able to launch new terminals (but with the wrong appearance shown above). If I install gnome-terminal I again lose the ability to launch new terminal windows. So I think I've lost the ability to launch a new gnome-terminal and all the new terminal windows I am creating are xterm terminals.

How can I restore my terminal appearance?

2 Answers 2

2

I did the following:

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

… as advised in this answer. For some reason, this restored my terminal appearance. Now, if I try:

sudo apt-get install python3

I get the following:

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)

… so obviously something's still not quite alright with my Python 3 (even though I can launch the Python 3 REPL from a terminal just fine) but at least my terminals now look normal.

1

You successfully screwed up your system. Never remove or otherwise break the python or python3 versions that come preinstalled with Ubuntu! Many important system components require one of these to work.

Now about trying to fix things again:

Seemingly your package manager apt still works, so go and check out /var/log/apt/history.log. This logfile contains all package management actions that were performed recently. Check which packages got removed during your process (including all those packages which were automatically removed because they depended on Python) and add them back.

After undoing all removals this way, your system should be back in its old state.

5
  • /var/log/history.log does not exist. I think I can see which packages got removed. When you advise to "undo all removals", you mean to apt-get install those packages again, right? Mar 30, 2018 at 15:50
  • 1
    Oops, I meant /var/log/apt/history.log, fixed that. Yes, install them again using e.g. sudo apt install PACKAGENAME.
    – Byte Commander
    Mar 30, 2018 at 15:57
  • 1
    upvoted because it's useful but I ended up in a mire trying to re-install everything. I posted as an answer what I did that got me out of this (even though the state of my Python 3 package is likely broken beyond redemption). It is also likely that the re-installs I did (as you advised) also helped. Mar 30, 2018 at 18:24
  • BTW, apart from removing what would be another way to "otherwise break" the python or python3 versions that come preinstalled with Ubuntu? And more to the point, how am I supposed to know which python or python3 versions "come preinstalled with Ubuntu" ? Mar 31, 2018 at 0:27
  • 1
    For example, people often want to make python start a Python 3 by default, which breaks lots of things. I think these two are the most frequent problems, removing one or replacing one with the other. There are many ways to break things, but one has to put some effort in it to think about more. If you check apt policy python python3 that should report you the available versions for Python 2/3 packages. Check for the highest version number that comes from an official Ubuntu repository and not from a PPA or external site. That is the one you should use. For 16.04 it is 3.5.1 and 2.7.12.
    – Byte Commander
    Mar 31, 2018 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.