How to update python for ubuntu server

Sometimes, official package manage software like apt may not up to date while you need to use the latest version of python. So you need to update it manually. Let’s do it.

How to update Python on Ubuntu

Log into your server as root. Let us assume you want to update to the latest version.

1
2
3
4
5
6
7
8
9
python3 --version # check your current python version
sudo apt update && sudo apt upgrade -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
apt list | grep python3.13 # Check if Python 3.13 is available
sudo apt install python3.13
python3.13 --version # check if python 3.13 installed successfully
wget https://bootstrap.pypa.io/get-pip.py # download python file for installing pip
python3.13 get-pip.py # install pip
1
vim .bashrc # create alias
1
2
alias python='python3.13'
alias pip='python3.13 -m pip'

Reference

  1. https://cloudbytes.dev/snippets/upgrade-python-to-latest-version-on-ubuntu-linux#google_vignette
  2. https://pip.pypa.io/en/stable/installation/