温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何把Ubuntu16和18上的python升级到最新python3.8

发布时间:2021-05-19 14:03:44 来源:亿速云 阅读:537 作者:小新 栏目:开发技术

小编给大家分享一下如何把Ubuntu16和18上的python升级到最新python3.8,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

1. 概述

本文记录在 Ubuntu 16.04 上将 python 升级为 3.8 版本,并配置为系统默认 python3 的过程。

在 Ubuntu 16.04 中,python3 的默认版本为 3.5:

$ python3 -V
Python 3.5.2

本文以在 Ubuntu 16.04 中安装为例,方法同样适用于 Ubuntu 18.04 。

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

Press [ENTER] to continue or Ctrl-c to cancel adding it.

2.3. 安装 python 3.8

$ sudo apt install python3.8

$ python3.8 -V
Python 3.8.2

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.5
/usr/bin/python3.5

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

3.2. 配置 python3 默认指向 python3.8

$ sudo update-alternatives --config python3

There are 2 choices for the alternative python3 (providing /usr/bin/python3).

 Selection Path  Priority Status
------------------------------------------------------------
* 0  /usr/bin/python3.5 2  auto mode
 1  /usr/bin/python3.5 2  manual mode
 2  /usr/bin/python3.8 1  manual mode

Press <enter> to keep the current choice[*], or type selection number: 2

选择/输入 2, 回车。

3.3 测试 python 版本

$ python3 -V

Python 3.8.2

资源

How to Install Python 3.8 on Ubuntu 18.04

How to upgrade to python 3.7 on Ubuntu 18.10

以上是“如何把Ubuntu16和18上的python升级到最新python3.8”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI