Skip to main content

Ubuntu 20.04 comes with Python 3.8 installed.  If you run the update script, you'll be informed that the latest version of Python is running.  But here is the kicker, the actual latest version is currently 3.11.6... see https://www.python.org/downloads/source/

Use the following commands to download the Python 3.11.6 source code

 

Download the latest version

cd /usr/src 
sudo wget https://www.python.org/ftp/python/3.11.6/Python-3.11.6.tgz 

 

Extract archive

Once the download is finished, extract the archive file content.

sudo tar xzf Python-3.11.6.tgz 

Prepare the source code as per your system architecture and environment. Also, we'll use --enable-optimizations option with configure command to enable additional supports like SSL, bz2 support.

cd Python-3.11.6
sudo ./configure --enable-optimizations

 

Compile and install

Now it's time to compile using the make command.  We are using make altinstall, to install it as a separate Python.  Therefore, this will not overwrite the existing Python installation.

sudo make altinstall

 

Check Python Version

Run the following command to check the version

python3.11 -V

Response

Python 3.11.6

 

Installing PIP

PIP will not be installed by default if you used the package manager.  If this is the case, install it manually.  To install PIP, execute the following command

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11

Once the PIP is installed successfully, check its version by executing the command:

pip3.11 -V

Response

pip 22.3.1 from /usr/local/lib/python3.11/dist-packages/pip (python 3.11)

 

Related articles

Andrew Fletcher01 May 2024
Common commands used in Ubuntu - in progress
A growing list of commands I've used and what they do in no specific ordersudo snap install bw ps aux | grep java whoami ip addr show uptime sudo apt update && sudo apt upgrade -y cat /etc/os-release sudo apt-get install needrestart sudo reboot sudo needrestart sudo ckan sysadmin...