-2

I already have installed python3.7 (via package management, as it is part of the offical ubuntu repositories) but if I wish to remove python3.6 (sudo apt remove python3.6), apt suggests to remove all sorts of stuff like libreoffice. I guess libreoffice could also use 3.7 but the package management can't just "switch" dependencies.

edit:

All packages are installed in the latest Version. I did just updated:

sudo apt update
sudo apt upgrade
sudo apt dist-upgrade

edit2:

I think the problem is of that kind: There are packages which has python 3 as dependency. Now that I have installed 3.7 and try to remove 3.6, package management thinks, that dependencies are not satisfied any more.

If that is not the case, how can I list packages which are installed and depend on 3.6 but not on 3.7?

edit3:

It is not practical to uninstall python3.6 as a lot of packages depending on this very version and are not satisfied with 3.7. For example gedit does not like 3.7: https://packages.ubuntu.com/cosmic/gedit

2 Answers2

1

You can't remove the 'older' Python version without breaking your system. Unlike from-source installs which rely on ldconfig and the LD Linker to link to their libraries and can sometimes do a link to an updated library source, Ubuntu and Debian packages define their dependencies at compile time in the package metadata itself. This metadata is locked once the package is published, so if you attempt to remove a dependency such as the older Python, your system will undoubtedly explode because all those Python scripts and libraries that everything depends on "might be removed". This is why you can't just "uninstall" your old Python without breaking other packages in your system.

If you want newer Python, either install the new package alongside the existing system-installed Python version, install it from source or use a method in How do I install the latest Python 2.7.X or 3.X on Ubuntu? and then use virtualenv to build Python virtual environments against those newer binary versions; this way you can use different Python versions for different projects. You really should not be ripping out your system-installed Python just so you can have the 'latest and greatest' versions. Some newer Python may be in the repositories, but I'll guarantee you that the rest of the packages aren't yet depending on those 'newer versions', so you still can't safely remove the system-shipped 3.6 yet.

Thomas Ward
  • 74,764
  • I have installed python3.7 via package management. 3.7 is in the official repositories. I did not install it from source. –  Nov 01 '18 at 14:05
  • @mogoh the second part is still relevant, whether it's installed from source or not. The package metadata system is what defines the dependencies, your LibreOffice version wasn't updated to have the newer dependencies. I would just have both Python versions installed, since it's very likely the rest of the system dependencies don't have Python 3.7 as a supported version added to them either (see my "Why don't the Ubuntu repositories have the latest versions of software" question for details as to why that may be the case about not updated packaging deps) – Thomas Ward Nov 01 '18 at 14:07
  • In short, please don't remove 3.6, you just can't – Alvin Liang Nov 01 '18 at 15:27
1

Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
tar -xvf Python-3.7.1.tgz
cd Python-3.7.1
sudo ./configure --enable-optimizations
sudo make -j8
sudo make install

You can keep both python versions and use the one as per your requirement. I don't think its a good idea to remove it, but if you still want to remove python3.6 below command should do the trick:

sudo apt-get purge python3.6

Ubuntu also depends on python to function, be extremely cautious of what you are doing.

Mitch
  • 107,631
  • I have already installed 3.7 via package management. I do not need to install the it. –  Nov 01 '18 at 14:06