ubuntu 下切换python版本. ubuntu下如何切换程序版本
ubuntu下ros和conda安装后都会改变python的默认环境,且需要用到的python版本各不相同,安装好后我们可能需要对系统的默认python指定进行微调。
1.首先用ls /usr/bin/python 查找出来系统python2 和 python3的版本
samsu@samsu-pc:~/anaconda3/bin$ ls /usr/bin/python*
/usr/bin/python /usr/bin/python3.6-config
/usr/bin/python2 /usr/bin/python3.6m
/usr/bin/python2.7 /usr/bin/python3.6m-config
/usr/bin/python2.7-config /usr/bin/python3-config
/usr/bin/python2-config /usr/bin/python3m
/usr/bin/python2-qr /usr/bin/python3m-config
/usr/bin/python3 /usr/bin/python-config
/usr/bin/python3.6
2.这里笔者的系统版本分别为2.7和3.6。然后输入下面两个指令把2.7版本和3.6版本的python分别加入列表中
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
注意:如果你在上一步中查明的python版本和读者不一样,那请把命令中python版本改成自己对应版本。
3. 使用下面命令列出已经配置版本
update-alternatives --list python
samsu@samsu-pc:~$ update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.6
4.然后就可以用下面的指令来切换系统默认的python版本了
update-alternatives --config python
samsu@samsu-pc:~$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.6 2 auto mode
* 1 /usr/bin/python2.7 1 manual mode
2 /usr/bin/python3.6 2 manual mode
Press <enter> to keep the current choice[*], or type selection number:
————————————————
版权声明:本文为CSDN博主「samsu0108」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/samsu0108/article/details/121220366
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架