Install Python 3.10.x on Ubuntu 20.04

問題描述

在做一些 Python 專案的時候,需要用到 Python 3.10.x 以上的版本,但是 Ubuntu 20.04 預設的 Python 版本是 3.8.x,所以需要安裝 Python 3.10.x。

解決方法

Prerequisite

1
2
sudo apt update
sudo apt install software-properties-common -y

Add custom APT repository

1
2
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update

Press ENTER to confirm adding repository.

Install Python 3.10

1
2
3
sudo apt install python3.10 python3.10-venv python3.10-dev
python3.10 --version # Check Python version
sudo apt install python3.10-pip # Install pip for Python 3.10

參考資料