新闻动态

Ubuntu下安装卸载python3.8的过程

发布日期:2022-01-31 19:19 | 文章来源:源码之家

一、Python 3.8 安装

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

$ python3 -V
Python 3.5.2

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

1.通过 Apt 安装Python3.8

Ubuntu 官方 apt 库中还未收录 python 3.8,这里使用 deadsnakes PPA 库安装。

1.1. 安装依赖包

$ sudo apt-get update
$ sudo apt-get install software-properties-common

1.2. 添加 deadsnakes PPA 源

$ sudo add-apt-repository ppa:deadsnakes/ppa
Press [ENTER] to continue or Ctrl-c to cancel adding it.

1.3. 安装 python 3.8

$ sudo apt-get update
$ sudo apt-get install python3.8
$ python3.8 -V
Python 3.8.2

2.配置 python3.8 为系统默认 python3

修改默认 python3 会导致打不开 Terminal 等各种问题,建议不要修改。解决方法见 Ubuntu16.04TLS 中终端(Terminal)无法打开的解决办法

2.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

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

$ sudo update-alternatives --config python3

There are 2 choices for the alternative python3 (providing /usr/bin/python3).
  Selection Path PriorityStatus
------------------------------------------------------------
* 0/usr/bin/python3.52auto mode
  1/usr/bin/python3.52manual mode
  2/usr/bin/python3.81manual mode
Press <enter> to keep the current choice[*], or type selection number: 2

选择/输入 2, 回车。

2.3 测试 python 版本

$ python3 -V
Python 3.8.2

二、卸载python3.8

1、卸载python3.8

sudo apt-get remove python3.8

2、卸载python3.8及其依赖

sudo apt-get remove --auto-remove python3.8

3、清除python3.8

sudo apt-get purge python3.8
or
sudo apt-get purge --auto-remove python3.8

注释:

此方法卸载python比较彻底,所以适合更换python版本时使用。

——对于既想完全卸载python,又无法接受完全卸载后某些python组件无法使用的童鞋,请慎重!

参考链接:

[1] 如何将 Ubuntu 16 和 18 上的 python 升级到最新 3.8 版

[2] Ubuntu安装Python3 和卸载

到此这篇关于Ubuntu下python3.8的安装与卸载的文章就介绍到这了,更多相关Ubuntu python3.8安装卸载内容请搜索本站以前的文章或继续浏览下面的相关文章希望大家以后多多支持本站!

国外服务器租用

版权声明:本站文章来源标注为YINGSOO的内容版权均为本站所有,欢迎引用、转载,请保持原文完整并注明来源及原文链接。禁止复制或仿造本网站,禁止在非www.yingsoo.com所属的服务器上建立镜像,否则将依法追究法律责任。本站部分内容来源于网友推荐、互联网收集整理而来,仅供学习参考,不代表本站立场,如有内容涉嫌侵权,请联系alex-e#qq.com处理。

相关文章

实时开通

自选配置、实时开通

免备案

全球线路精选!

全天候客户服务

7x24全年不间断在线

专属顾问服务

1对1客户咨询顾问

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部