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
@AmitS07
Copy link

AmitS07 commented Sep 23, 2022

Great! It helped me

@Muazzeem
Copy link

its helpful

@MosabAwadAhmedAlhadi
Copy link

yall really testing these commands on your laptops ? what docker or vm did to you to hate using it so much

@mohammadasim98
Copy link

Very nice. I just blew my VM. Thanks for nothing.

Copy link

ghost commented Feb 6, 2023

What the hell, my terminal got removed

@rajpatel8
Copy link

Ye kisne de diye baccho ke haath mein laptop

@WajahatRiaz
Copy link

DON'T TRY THIS AT HOME !!!!!!

@Alkhara
Copy link

Alkhara commented Mar 22, 2023

1st result when searching "ubuntu uninstall python" lmao

@komorebi64
Copy link

Thank you! My ubuntu was also broken😅

@xcybermanx
Copy link

Don't try it or will distroy Your ubuntu

@Amjdhassan
Copy link

how to get password

@MouadBH
Copy link

MouadBH commented May 4, 2023

too late to read the comments

@Magorick
Copy link

Thank you!!! I Just destroyed my ubuntu server

@Hurricane125
Copy link

Destroyed my entire fing Ubuntu install, If anyone sees this comment, I would highly advise against using these commands, It will trash your system, if you fall victim to this, enter TTY console if you can, and type sudo apt-get update --fix-missing, then once this finishes, enter sudo apt install -f, this will fix the Ubuntu install, if it doesn't you work you must reinstall Ubuntu somehow. For me, this method worked.

@centos-wheezy
Copy link

This page should be removed! The commands are destructive and achieve absolutely nothing. Removing Python 3 as it is described above will render your machine unusable. I tested the above commands on VirtualBox machine and it damaged the machine beyond repair. Luckily I had a backup. Again, DON'T USE THE ABOVE COMMANDS!! RUN DON'T WALK!!

@itzikwei
Copy link

please remove this page, not all people reading the comments, and it makes terrible results. just remove it

@aylinavch
Copy link

DON'T DO IT, IT WILL DESTROY THE DESKTOP!!!

sudo apt-get purge .... destroys dependencies and ubuntu desktop needs it (i think so...)

So try running:
sudo apt install --reinstall ubuntu-desktop
to solve this problem.

It has worked for me (for now haha) but it was also helpful running sudo apt-get install --reinstall pythonVERSION to reinstall everything that is needed.

(for me was python3.10, just look for it after reinstalling the desktop running /usr/bin/python3 and check which version you need)

@oleksandr-kupenko
Copy link

For the author of this manual there is a separate cauldron in hell.

@itzikwei
Copy link

Is there no way to report this person or something?
I can see he was active 12 minutes ago, which means he does see these comments, and still keeping this post.
There is something seriously wrong with your brain.

@nathanmuir23
Copy link

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

@oleksandr-kupenko
Copy link

oleksandr-kupenko commented Dec 29, 2023

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

@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