跳至内容
wiki
用户工具
登录
站点工具
搜索
工具
显示页面
过去修订
反向链接
导出 PDF
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您在这里:
start
»
linux
»
ubuntu
»
python3升级
您的足迹:
•
bit-vector
•
text-table
linux:ubuntu:python3升级
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
# 将 Ubuntu 16 和 18 上的 python 升级到最新 python3.8 的方法教程 https://www.jb51.net/article/182392.htm 在 Ubuntu 16.04 中,python3 的默认版本为 Python 3.5.2 像类似''print(f'hello')''这样的语句3.5还不支持,需要至少升级到3.6。<span style="color:#ed1c24">本文以在 Ubuntu 16.04 中安装为例,方法同样适用于 Ubuntu 18.04 。</span> 不太建议对系统的python版本进行升级,而是最好采用直接安装anaconda3的方式,这样没有依赖问题,免于折腾。 ## - 通过 Apt 安装 Ubuntu 官方 apt 库中还未收录 python 3.8,这里使用 deadsnakes PPA 库安装。 ### - 安装依赖包 ``` $ sudo apt update $ sudo apt install software-properties-common ``` ### - 添加源 ``` $ sudo add-apt-repository ppa:deadsnakes/ppa Press [ENTER] to continue or Ctrl-c to cancel adding it. ``` ### - 安装python 3.6及以上 ``` $ sudo apt install python3.8 $ python3.8 -V Python 3.8.2 ``` ## - 配置 python3.8 为系统默认 python3 ### - 将 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 ``` ### - 配置 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 ``` ### - 测试 python 版本 ``` $ python3 -V Python 3.8.2 ```
linux/ubuntu/python3升级.txt
· 最后更改:
2026/10/14 06:39
由
127.0.0.1
页面工具
显示页面
过去修订
反向链接
导出 PDF
回到顶部