Skip to content

Instantly share code, notes, and snippets.

@soos3d
Forked from zhensongren/uninstall_python3.MD
Last active June 26, 2024 13:50
Show Gist options
  • Save soos3d/c4fe369a278d94fa5acc1ca22f1348c8 to your computer and use it in GitHub Desktop.
Save soos3d/c4fe369a278d94fa5acc1ca22f1348c8 to your computer and use it in GitHub Desktop.
How to uninstall python3 from Ubuntu

How to uninstall and re-install Python 3 on Ubuntu

Uninstall and re-install Python 3 on Ubuntu 20.04 lts.

Table of contents

Uninstall Python3

List all python versions in default locations

ls /usr/bin/python* 

Remove just the python3 package

sudo apt-get remove python3.5

Remove it's dependent packages

ATTENTION! The next part of the process might delete the ubuntu GUI, use this command to re-install it. sudo apt install ubuntu-desktop

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

Remove the configuration and/or data files of python3

sudo apt-get purge python3.5

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

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

Install a new version of python

sudo apt-get update
sudo apt-get install python3

Verify the installation.

python3

You should see something like the following.

Python 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

ModuleNotFoundError: No module named '_sqlite3'.

sudo apt-get install libsqlite3-dev
./configure --enable-loadable-sqlite-extensions && make && sudo make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment