Upgrade Python to latest version on Ubuntu Linux
- First, update your system by running
1
| sudo apt update && sudo apt upgrade -y
|
1 2
| sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update
|
- Check if Python 3.12 is available by running
1
| apt list | grep python3.12
|
- Install Python 3.12
1
| sudo apt install python3.12
|
- Run Python 3.12
The right way to run Python 3.12 On Linux Desktops is by using a virtual environment.
E.g. you can create a new virtual environment by running
and activate it by running
Now you can run python --version
and you should see the latest version of Python as the output.
參考資料:
Upgrading Python to the Latest Version on Ubuntu Linux