Skip to content

Instantly share code, notes, and snippets.

@bewithdhanu
Last active December 28, 2024 21:33
Show Gist options
  • Save bewithdhanu/0df8d6c71f149c45ac42fd1735f32518 to your computer and use it in GitHub Desktop.
Save bewithdhanu/0df8d6c71f149c45ac42fd1735f32518 to your computer and use it in GitHub Desktop.
Upgrade Python 3.10 to 3.11 on Ubuntu 22.04

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
pip install --upgrade pip setuptools

3.11 will be shown as version

python --version
@camilotorresmestra
Copy link

Thanks!

@WeeBigToe
Copy link

Thank you

@gcoghlan
Copy link

Thank you, these steps were really helpful for me too.

But a word of caution for Ubuntu 22-04, (I'm not sure if it applies to new Ubuntu versions): changing the default python3 version breaks the terminal app. (See https://askubuntu.com/questions/1442350/terminal-not-launching-in-ubuntu-22-04 for a discussion)

To avoid that, make sure that the existing python3 version has the highest priority, e.g.

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1

@aiaug
Copy link

aiaug commented Nov 27, 2024

very helpful

@credo1983
Copy link

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment