5

On Ubuntu 16.04 I installed Python 3.6 from the deadsnakes PPA. Now I upgraded to Ubuntu 18.04 which builds on top of Python 3.6 but instead of removing the old version of Python 3.6 it kept the version from the deadsnakes PPA which leads to dependency issues if I want to install anything related to python. For example, if I run sudo apt install python3.6-venv:

The following packages have unmet dependencies:
python3.6-venv : Depends: python3.6 (= 3.6.5-3) but 3.6.6-1+xenial1 is to be installed

Is there a safe way to remove 3.6.6-1+xenial1 without removing everything which depends on it to install the default Python 3.6? Otherwise, I would have to reinstall Ubuntu from scratch.

A related question is impossible to install with apt-get, python missing Unfortunately, the only answer given recommends manually removing and reinstalling python3.6 which would lead to the removal of about 218 packages. This is what I would like to circumvent. sudo apt-get remove python3.6:

The following packages will be REMOVED:
apparmor apport apport-gtk aptdaemon apturl apturl-common asymptote atom
cdbs command-not-found compiz compiz-gnome dh-python firefox
foomatic-db-compressed-ppds gconf2 gdm3 gedit gedit-common gir1.2-ibus-1.0
gnome-control-center gnome-menus gnome-online-accounts gnome-orca
gnome-shell gnome-software gnome-software-plugin-snap gnome-terminal
...
  • 1
    @Ray There's a way to uninstall a package without uninstalling its dependencies. I think it's an option called --force-dependencies but I can't check right now. – wjandrea Aug 19 '18 at 14:50
  • 1
    You should see what packages are currently installed from that ppa (synaptic could find easily). Any that can be removed without any potential issue should be. For any remaining locate and download the bionic package(s), if multiple put them in an empty folder & install all at once with dpkg, sudo dpkg -i *.deb A single package can just be installed directly with apt or dpkg. (try apt first) Current packages for bionic can be found easily with a web search of name.. – doug Aug 19 '18 at 16:08
  • 1
    This might help: stackoverflow.com/questions/50397705/… – WinEunuuchs2Unix Aug 19 '18 at 20:14
  • 1
    @Ray I've reinstalled Ubuntu more than once because it was the easiest way to fix a terrible mess left by some irreversible package removal operation. Oli4's caution is justified. If you're fine with reinstalling you can mess with package-management to your heart's content. Otherwise it's better to not remove things with many dependencies like python – Zanna Aug 27 '18 at 5:15
  • 1
    @Zanna I did not say Oli4's caution wasn't justified. And I have re-installed Ubuntu 4 times in one day on a machine just last week -- I know what you mean. What I mean is if you bypass the graphical interface, then you've reduced many problems. Many of the dependencies we're worried about are loaded in to memory and will be there during a quick uninstall, reinstall. So, that includes many of the dependencies we're talking about. I am not suggesting uninstalling and then logging out or rebooting! Because memory would be cleared and, yes, some problems may result. – Ray Aug 27 '18 at 13:07
5

After reading the comments below the question I successfully reinstalled python3.6 and want to share with you how I did it.

  1. I made a backup of all my data which I would recommend to everyone trying this. Although it worked for me it may fail for some reason on your machine and you don't want to lose your data.
  2. I made sure that the deadsnakes PPA is deactivated.
  3. I ran the following commands to remove the old version of python3.6 without removing all the dependencies and to directly install the default version.

    sudo dpkg --remove --force-depends python3.6 python3.6-minimal libpython3.6-minimal libpython3.6-stdlib
    sudo apt-get install python3.6 python3.6-minimal libpython3.6-minimal libpython3.6-stdlib
    
  4. I ran sudo apt-get update and sudo apt-get upgrade before rebooting my machine.

Maybe this is overcomplicated but it worked for me. Thank you very much for your comments @wjandrea, @Ray, @Zanna.

2

For those like me who confirm to delete the 200 packages, I've been able to use a non graphic session (Ctrl+Alt+F1) to reinstall gnome (or cinnamon, I had both installed and both were removed when I remove python3.6).

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.