- # 删除 Python —— 在运行前请再三确认
- # 这也会移除所有依赖于此的包,包括 gimp, mysql 等
- sudo apt purge python3
使用 PPA 源安装 Python使用如下所示的命令安装 Python 3.9 。在一些情况下,不推荐使用 PPA 安装 Python。在这种情况下,您可以按照下一节的方法从源代码安装。
- # 更新包目录
- sudo apt update
- # 安装依赖
- sudo apt install software-properties-common
- # 添加 deadsnakes PPA 源
- sudo add-apt-repository ppa:deadsnakes/ppa
- # 按下 Enter 以继续
- # 安装 Python 3.9
- sudo apt install python3.9
上述命令将在 /usr/lib/python3.9 安装 Python 3.9。默认的Python 3(即 Python 3.8)仍然安装于 /usr/lib/python3.8。现在使用如下所示的命令验证安装。 - # 检查 Python 版本
- python3.8 --version
- # 检查版本
- Python 3.8.2
- # 检查 Python 版本
- python3.9 --version
- # 检查版本
- Python 3.9.0
|