I'm running Ubuntu 16.04.3 LTS and accidentally uninstalled python2 and everything that depends on it. Edit: According to /var/log/apt/history.log, 326 modules were removed: pastebin.com (sorted alphabetically).

I've reinstalled python2 now but apparently a lot of things are still broken. Most urgently is obviously getting a functioning mouse back.

  • When I boot my computer, I arrive at my normal desktop. Keyboard and mouse pointer work just fine, but the mouse buttons only work in the launcher -- not on the desktop and not in any launched apps.

  • I can use the mouse to launch a terminal, then type unity --replace & into a terminal (as advised in older posts). Having done that, the mouse now works inside the terminal window but not on the window frame nor anywhere else!

  • I can Ctrl+Alt+F2 and run unity --replace & from there. That appears to end the command I had running in the previous step, and when I go back to Ctrl+Alt+F7 then the mouse is working normally - but Unity's top menu bar (including the clock and system/power button) is blank.

It's a Logitech wireless mouse (M705) and I have put in a pair of fully charged batteries just to be sure and rule out the hardware.

--> What am I missing, and how do I restore my mouse clicks to normal operation without the unity workaround?

  • Removing python2 removed also all packages which depend on it. Just reinstalling python2 does not reinstall these packages. You should check in /var/log/apt/history.log which packages have been removed and reinstall them manually. I believe, this is a long list. Maybe someone here can provide a script to do that, but that's above my skills. Is this python2.7 which you removed accidentally? – mook765 Oct 28 '17 at 9:23
  • Do mouse keys work? (help.ubuntu.com/stable/ubuntu-help/mouse-mousekeys.html) – Geoffrey Wheeler Oct 28 '17 at 10:13
  • I don't understand how the mouse buttons depend on Python. @mook765 I added a []pastebin link](pastebin.com/raw/9GAiMMFm) above that lists the removed modules. Do you recommend that I reinstall ALL of them, or any in particular? – Torben Gundtofte-Bruun Oct 28 '17 at 16:21
  • I cant' help you much with that. Fact is that removing python2 removed a lot of packages and after that you are facing problems. I don't know which of these packages are relevant for the mouse. I would reinstall all of them, just to make sure that you will not face other issues in the future. It might be a bit ugly work to do that manually, but to be honest, what choices do you have? If a complete reinstall is an option for you, that might be less time-consuming. That's life, accidents happens. Always be careful when running with root-privileges. – mook765 Oct 28 '17 at 16:39
  • @mook765 you're absolutely right. And I am considering a reinstall, just to be sure. I'll first see how much trouble it is to reinstall the modules. Thanks. – Torben Gundtofte-Bruun Oct 28 '17 at 19:33

I did something similar with another package and partially took down my desktop. Wouldn't accept any keyboard or mouse inputs. I had to ssh in from another computer to implement the repair (probably could have booted into text mode as well).

I found this handy line somewhere; on this site I think:

sudo apt-get install `grep Remove /var/log/apt/history.log | tail -1 | sed -e 's|Remove: ||g' -e 's|([^)]*)||g' -e 's|:[^ ]* ||g' -e 's|,||g'` 

Basically creates a list of all the removed packages and reinstalls them. Just run the grep part first to get a sense of what will be reinstalled.

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.