Skip to content

Instantly share code, notes, and snippets.

@zhensongren
Last active October 13, 2024 19:58
Show Gist options
  • Save zhensongren/811dcf2471f663ed3148a272f1faa957 to your computer and use it in GitHub Desktop.
Save zhensongren/811dcf2471f663ed3148a272f1faa957 to your computer and use it in GitHub Desktop.
How to uninstall python3 from Ubuntu

To list all python versions in default locations

ls /usr/bin/python*

To remove just python3 package

sudo apt-get remove python3.5

plus it's dependent packages

sudo apt-get remove --auto-remove python3.5

plus configuration and/or data files of python3

sudo apt-get purge python3.5

both configuration and/or data files of python3.5 and it's dependencies

sudo apt-get purge --auto-remove python3.5

How to install new version of python

sudo apt-get update

sudo apt-get install python3

Also, see https://docs.python-guide.org/starting/install3/linux/ or install python3.8 https://linuxize.com/post/how-to-install-python-3-8-on-ubuntu-18-04/

ModuleNotFoundError: No module named '_sqlite3'.

  • sudo apt-get install libsqlite3-dev
  • ./configure --enable-loadable-sqlite-extensions && make && sudo make install
@gamedev8
Copy link

gamedev8 commented Jan 22, 2024

next time, i will read the comments before reading the post :D because i just destroyed my distribution

as said above, command sudo apt install --reinstall ubuntu-desktop fixes the problem. But you need an automatic Internet connection, as it can be difficult to set up through the console

That lone command will not restore everything that was removed. It will only restore ubuntu-desktop and its dependencies! You'll need to make an install script out of everything that got removed.

For example on my machine I'd have to run the following. It will be different for everyone, because it depends what you had installed.

sudo apt install apport apport-gtk aptdaemon apturl apturl-common boot-repair boot-sav boot-sav-extra command-not-found deja-dup duplicity foomatic-db-compressed-ppds gdm3 gedit gedit-common glade2script glade2script-python3 gnome-control-center gnome-menus gnome-online-accounts gnome-shell gnome-shell-extension-appindicator  gnome-shell-extension-desktop-icons-ng gnome-shell-extension-ubuntu-dock gnome-terminal gnome-user-docs gvfs-backends hplip hplip-data ibus ibus-table language-selector-common language-selector-gnome libsmbclient libwacom-bin llvm-14-dev llvm-14-tools llvm-15-dev llvm-15-tools lsb-release nautilus-extension-gnome-terminal nautilus-share netplan.io networkd-dispatcher nvidia-prime nvidia-settings openprinting-ppds orca pastebinit plymouth-theme-spinner plymouth-theme-ubuntu-text postgresql-server-dev-15 printer-driver-foo2zjs printer-driver-foo2zjs-common printer-driver-m2300w printer-driver-postscript-hp printer-driver-ptouch printer-driver-pxljr printer-driver-sag-gdi rhythmbox-plugin-alternative-toolbar rhythmbox-plugins samba-libs screen-resolution-extra software-properties-common software-properties-gtk system-config-printer system-config-printer-common system-config-printer-udev totem-plugins ttf-mscorefonts-installer ubuntu-advantage-desktop-daemon ubuntu-advantage-tools ubuntu-desktop ubuntu-desktop-minimal ubuntu-docs ubuntu-drivers-common ubuntu-minimal ubuntu-pro-client-l10n ubuntu-release-upgrader-core ubuntu-release-upgrader-gtk ubuntu-session ufw unattended-upgrades update-manager update-manager-core update-notifier update-notifier-common usb-creator-common usb-creator-gtk xorg xserver-xorg yelp

When you are uninstalling python3 it will tell you every package that will also be removed. That's how you build your reinstall script - just copy everything into a single line, then add sudo apt install in front.

Of course this is after you reinstall python.

@P4R0D-Y
Copy link

P4R0D-Y commented Mar 8, 2024

OMG you are a mfcker. I got my VM almost completely destroyed but i got to recover it. You are a piece of crap.

@jasonm23
Copy link

jasonm23 commented Mar 18, 2024

OK ... NOT ALL OF YOU KNOW THIS...

PYTHON IS USED EXTENSIVELY IN MOST LINUX DISTROS, ESPECIALLY IN GUI/DESKTOP

DO NOT DO THIS UNLESS YOUR INTENT IS TO REINSTALL PYTHON IMMEDIATELY AND YOU KNOW WHAT YOU ARE DOING !!!!!!!!!!!

@jarodsim
Copy link

I just broke my father SO AHAHHAHHAHAHA OOOOOOOOO NO

@adith-p
Copy link

adith-p commented Jul 5, 2024

this page is still up 🤣

@grepwood
Copy link

The Great Filter be like:

@jugal-sheth
Copy link

OK ... NOT ALL OF YOU KNOW THIS...
PYTHON IS USED EXTENSIVELY IN MOST LINUX DISTROS, ESPECIALLY IN GUI/DESKTOP
DO NOT DO THIS UNLESS YOUR INTENT IS TO REINSTALL PYTHON IMMEDIATELY AND YOU KNOW WHAT YOU ARE DOING !!!!!!!!!!!

@jasonm23
Copy link

@jugal-sheth NOW THAT'S VALUE ADDING!!!

@flyzomap
Copy link

I spoiled my ubuntu. Please remove this message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment