- Published on
Install a specific Python version on Ubuntu
- Authors
- Name
- Ruan Bekker
- @ruanbekker
In this short tutorial, I will demonstrate how to install a spcific version of Python on Ubuntu Linux.
Dependencies
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 https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz
Then extract the tarball:
$ tar -xvf Python-3.8.13.tgz
Once it completes, change to the directory:
$ cd Python-3.8.13
Installation
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 subscribe to my newsletter or follow me at @ruanbekker on Twitter.
- Linktree: https://go.ruan.dev/links
- Patreon: https://go.ruan.dev/patreon