debian10中切换系统默认python版本基于系统层面修改方法

先来查看一下系统中有几个python版本

ls /usr/bin/python*

- 1607094700 5d518828ff221e1

查看python版本号

python --version

- 1607094873 8a993752e9658af

update-alternatives --list python

报错这个update-alternatives: error: no alternatives for python,代表 Python 的替代版本没有被 update-alternatives 命令识别

- 1607095611 317823ff7efb55a

敲入python,按键盘tab键显示下列
也可以使用ls /usr/bin/python*
root@:~# python
python             python2-config     python3.6          python3-config
python2            python3            python3.6-config   python3m
python2.7          python3.5          python3.6m         python-config
python2.7-config   python3.5m         python3.6m-config  

然后我们需要更新一下替代列表,将 python2.7 和 python3.6 放入其中alternatives

update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode

update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode

列出可用的python替代版本

update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.6
使用这条命令就可以任何切换python版本了

update-alternatives --config python

最后如果系统中替代版本只需要留一个,那就移除替代版本

使用命令移除
update-alternatives --remove python /usr/bin/python2.7

update-alternatives: removing manually selected alternative - switching python to auto mode
update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode
上一篇 如何一条指令查询linux上运行的python程序
下一篇 Vultr新用户优惠 赠100美元测试金 32 个机房 VPS 云服务器 支持多支付方式

投稿邮箱:
[email protected] (投稿详情)

TG订阅频道:
t.me/ivpsr_news 网站最新内容推送

TG交流群:
(点击加入) 用户交流

文章列表
1
简单易操作的wordpress网站快速更换域名方法
简单易操作的wordpress网站快速更换域名方法
2
Fourplex美国VPS $3.5/月起,纽约机房,双核AMD Ryzen/2GB内存/20GB NVMe硬盘/不限流量
Fourplex美国VPS $3.5/月起,纽约机房,双核AMD Ryzen/2GB内存/20GB NVMe硬盘/不限流量
3
YinNet德国双ISP住宅IP VPS上新,7折优惠$8.4/月,解锁TikTok流媒体
YinNet德国双ISP住宅IP VPS上新,7折优惠$8.4/月,解锁TikTok流媒体
4
Gcore | 3.6折即可获得Gcore裸金属服务器
Gcore | 3.6折即可获得Gcore裸金属服务器
5
RAKsmart独立服务器世界杯促销6折起,美国 CN2 VPS$2.99/月起,日本独服$49.9/月起
RAKsmart独立服务器世界杯促销6折起,美国 CN2 VPS$2.99/月起,日本独服$49.9/月起
6
raksmart美国高防服务器$79/月起,圣何塞机房/1Tbps高防保护,自定义配置
raksmart美国高防服务器$79/月起,圣何塞机房/1Tbps高防保护,自定义配置
7
HostSailor荷兰VPS年付3折$17.96/年,AMD EPYC单核、1GB内存、30GB NVMe、1TB流量1Gbps带宽
HostSailor荷兰VPS年付3折$17.96/年,AMD EPYC单核、1GB内存、30GB NVMe、1TB流量1Gbps带宽
8
winnervps:印度尼西亚机房简单测评,实测数据详情带你深入了解
winnervps:印度尼西亚机房简单测评,实测数据详情带你深入了解
9
DediPath:夏季特惠继续进行,全场VPS和混合服务器5折,独立服务器E3-1240v2再次大幅打折低至$39/月
DediPath:夏季特惠继续进行,全场VPS和混合服务器5折,独立服务器E3-1240v2再次大幅打折低至$39/月
10
云途香港VPS优惠后低至89元/年,单核1GB、10GB NVMe、300GB流量200Mbps带宽、赠送CNIX
云途香港VPS优惠后低至89元/年,单核1GB、10GB NVMe、300GB流量200Mbps带宽、赠送CNIX