As of Ubuntu 24.04's release, Python 3.11 may not be available directly through the official Ubuntu repositories or through Deadsnakes PPA, for instance.
You could, in this case, build Python 3.11 from source.
However, as of my latest check, the Deadsnakes PPA has already updated its support for Ubuntu 24.04 (Noble). So you can just
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.11
https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
I believe a more contemporary and efficient method exists for installing a tailored version of Python, accompanied by a virtual environment, without relying on pip:
apt-get update && apt-get install -y uv
uv venv --python 3.11
Best practice: avoid modifying the system Python to prevent potential disruptions to the operating system's dependencies.
trying to install python 3.11
Can't run pip on python 3.11 - Stack Overflow
Ubuntu touch can support python 3.11 ?
I have Pycharm and VsCode in Libertine containers. Probably you can also install Python 3.11. Just saying, not tested
More on reddit.comAnyone know when Python 3.11 will be available for upgrade in the repos?
Videos
I installed Python3.11 from the deadsnakes ppa, it doesn't come with ensurepip or pip, and the bootstrap script initially fails as it depends on distutils. I solved this by installing the optional distutils package and then bootstrapping.
apt install python3.11 python3.11-distutils
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
sudo apt install python3.11-venv # as ensurepip is not installed at first
python3.11 -m ensurepip