How to Upgrade Python on Debian, Ubuntu and Kali Linux (and Set the Default Version Safely)

Updated October 2026: this page replaces six separate posts I wrote between 2019 and 2021 about upgrading Python on Debian 9 and 10, Ubuntu 19.10 and Kali, and switching the python command from 2.7 to 3. The old URLs redirect here. Everything in the first half was re-tested on 8 October 2026 in fresh Debian 12 and Ubuntu 22.04 containers. The original 2019 from-source walkthrough is kept at the end because it still works, with one important correction. ...

February 19, 2019 · 6 min · Tom Cocking