Python 3.12.0 final was officially announced this Monday! Ubuntu LTS can easily install it from PPA.
New features in Python 3.12.0:
- More flexible f-string parsing, allowing many things previously disallowed.
- Python-level API for the buffer protocol
- New API for monitoring Python programs running on CPython at low cost.
- Per-Interpreter Global Interpreter Locks
- Support for the Linux perf profiler to report Python function names in traces.
- New type annotation syntax for generic classes
- New decorator
typing.override()in the typing module.
The new Python release also removed a few deprecated modules, including
distutils. For Ubuntu 22.04, Ubuntu 20.04, it causes a broken pip. As a workaround, you need to manually install pip for Python 3.12.
How to Install Python 3.12.0 in Ubuntu:
For Ubuntu 22.04, Ubuntu 20.04, and their derivatives such as Linux Mint 21, the Deadsnakes PPA has made the packages for all supported CPU architecture types: amd64, arm64/armhf, ppc64el, and s390x.
1. First, press Ctrl+Alt+T on keyboard to open terminal. Then paste the command below and hit run to add PPA:
sudo add-apt-repository ppa:deadsnakes/ppa
Type user password (no asterisk feedback) when it asks and hit Enter to continue.
2. Ubuntu 20.04+ automatically refresh package cache while adding PPA. However, Linux Mint user may need to do this job manually by running command:
sudo apt update
3. Finally, run command to install Python 3.12:
sudo apt install python3.12
For other Ubuntu editions, you may manually compile Python 3.12 from source tarball.