Upgrade Python 3.10 to 3.11 on Ubuntu 22.04
Python 3.10 was provided by Ubuntu 22.04 as default.
This post shows how to upgrade python from 3.10 to 3.11.
1. Upgrade Python from 3.10 to 3.11
2. Install pip
1. Upgrade Python from 3.10 to 3.11
# Check python version use python and python3
# The first comman will Not show version info.
# The second one show 3.10 as version as it is provided by ubuntu as default
python --version
python3 --version
# Add additional repository to download python 3.11
sudo add-apt-repository ppa:deadsnakes/ppa
# This might take more than few minutes
sudo apt update
sudo apt upgrade
# Install python 3.11
sudo apt-get install python3.11
# python3 shows 3.10 and python3.11 shows 3.11 as version
python3 --version
python3.11 --version
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2
sudo update-alternatives --config python3
#choose 2 for python 3.11
# 3.11 will be shown as version
python3 --version
sudo apt install python-is-python3
# 3.11 will be shown as version
python --versionNote:
You might get error “ModuleNotFoundError: No module named ‘apt_pkg’” when “sudo apt update” was executed later. Such error can also occured when installing azure-cli. One solution could be:
cd /usr/lib/python3/dist-packages/
cp apt_pkg.cpython-310-x86_64-linux-gnu.so apt_pkg.so2. Install pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
python -m pip --version
# You can also do this for ~/.zshrc
nano ~/.bashrc
# add this line to the end of file, save and exit the file
alias pip='python -m pip'
pip --version
pip install --upgrade pipThank you for reading. I hope you enjoyed today’s content.
If you have any suggestion to improve this article, please let me know.
You are welcome to my network:
Follow me on Medium






