Uninstalling Python

Uninstalling Python

I have two versions of python3 (3.5 and 3.8) on the same machine(ubuntu 16.04). And I guess the installation is broken. I want to uninstall them completely and install afresh. Can someone tell me the safest way of doing this without messing up dependencies ?

EDIT: tarball-extract-config that's how i installed v3.8

答案1

I want to uninstall them completely and install afresh. Can someone tell me the safest way of doing this without messing up dependencies?

This exact goal won't be possible, uninstalling a package will uninstall all the packages which depend on it. Additionally the python3 package that came with Ubuntu 16.04 is likely depended upon by many vital system packages like gnome-shell for instance.

I would recommend finding the package from which python3.8 came and uninstalling just that package. You can find the package which provides it with the following command:

dpkg -S $(which python3.8)

Which should print out something like:

package-name: /usr/bin/python3.8

You can take the actual name (as represented by package-name) and find what depends upon that you have installed with this command (again replacing package-name with the name you got from the above command:

apt-cache rdepends --installed package-name

Save this list somewhere and review it to make sure you're ok with uninstalling these packages. If you are happy with uninstalling those packages you can do so with:

sudo apt-get purge package-name

This will uninstall the package and all the related configuration files. You might want to then try reinstalling the standard python3 package to regenerate any configuration files that might have gotten overwritten by the package which provided python3.8 and were subsequently removed. You can do that with:

sudo apt-get reinstall python3

Then you should be back to (relatively) clean python state. Again I would make sure you're comfortable removing everything which depends on Python 3.8 but on Ubuntu 16.04 that shouldn't be any vital system software.

相关内容