Skip to main content

Command Palette

Search for a command to run...

How to re-install Python 3 on Ubuntu

Updated
2 min read
How to re-install Python 3 on Ubuntu
D

Hey there! I'm Davide, a passionate developer advocate at Chainstack, the leading suite of blockchain infrastructure services.

I'm dedicated to empowering current and aspiring web3 developers by sharing valuable content and resources.

Within my articles, you'll discover a treasure trove of straightforward projects designed to bolster your understanding of fundamental Python, Solidity, JavaScript, and web3 skills. Whether you're a seasoned developer or just starting out, these projects offer an ideal learning path for honing your abilities in the exciting world of blockchain development.

Feel free to explore my articles, and let's embark on this remarkable journey of mastering web3 together!

Python can be tricky to work with, especially when avoiding conflicts. You may need to remove all of the Python versions and re-install it.

Let's see how to do it!

I keep these installation tutorials simple and straightforward because I know how frustrating it is to read through an entire article when you are simply looking for terminal commands. So if this article looks bland, it is very much on purpose :)

Uninstall Python3

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

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

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