1、查看当前python版本

$ python3 -V
3.6.9
2、通过 apt 进行安装
Ubuntu 官方 apt 库中还未收录 python 3.8,这里使用 deadsnakes PPA 库安装。
2.1 安装依赖包
$ sudo apt update
$ sudo apt install software-properties-common


2.2 添加 deadsnakes PPA 源
$ sudo add-apt-repository ppa:deadsnakes/ppa

2.3 安装python3.8
$ sudo apt install python3.8

3、配置Python3.8为系统默认Python3版本
3.1 将 python 各版本添加到 update-alternatives
$ which python3.8
/usr/bin/python3.8
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1

$ which python3.6
/usr/bin/python3.6
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

3.2 配置 python3 默认指向 python3.8

4、测试Python3版本

这篇博客介绍了如何在Ubuntu系统中通过apt安装Python3.8,详细步骤包括更新软件包列表,添加PPA源,安装Python3.8,并将其配置为系统默认的Python3版本。
3446

被折叠的 条评论
为什么被折叠?



