My Ubuntu 22.04 (WSL) comes with Python 3.10.6, and I need to upgrade it to 3.11 for a workshop. (More importantly is, it claims to be 10-60% faster than the previous 3.10. 😎
Here are the steps:
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.11-full
$ python3.11 --version
Python 3.11.1
Next. To set Python 3.11 as default.
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 110
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100
$ sudo update-alternatives --config python3