Published on

Install a specific Python version on Ubuntu



In this short tutorial, I will demonstrate how to install a spcific version of Python on Ubuntu Linux.

Say Thanks! Ko-fi


Update the apt repositories:

$ sudo apt update

Then install the required dependencies:

$ sudo apt install libssl-dev openssl wget build-essential zlib1g-dev -y

Python Versions

Head over to the Python Downloads section and select the version of your choice, in my case I will be using Python 3.8.13, once you have the download link, download it:

$ wget

Then extract the tarball:

$ tar -xvf Python-3.8.13.tgz

Once it completes, change to the directory:

$ cd Python-3.8.13


Compile and add --enable-optimizations flag as an argument:

$ ./configure --enable-optimizations

Run make and make install:

$ make 
$ sudo make install 

Once it completes, you can symlink the python binary so that it's detected by your PATH, if you have no installed python versions or want to use it as the default, you can force overwriting the symlink:

$ sudo ln -fs /usr/local/bin/python3 /usr/bin/python3

Then we can test it by running:

$ python3 --version
Python 3.8.13

Thank You

Thanks for reading, if you like my content, feel free to check out my website, and subscrube to my newsletter or follow me at @ruanbekker on Twitter.

Buy Me A Coffee