Ubuntu 修改默认 Python 版本

系统环境Ubuntu 18.04

 

首先查看安装了哪些Python:

root@wayde-desktop:/home/wayde/Documents/civ#  ls /usr/bin/python*
/usr/bin/python   /usr/bin/python2.7         /usr/bin/python2-config  /usr/bin/python3.6         /usr/bin/python3.6m         /usr/bin/python3-config  /usr/bin/python3m-config
/usr/bin/python2  /usr/bin/python2.7-config  /usr/bin/python3         /usr/bin/python3.6-config  /usr/bin/python3.6m-config  /usr/bin/python3m        /usr/bin/python-config

 

查看当前默认版本:

root@wayde-desktop:/home/wayde/Documents/civ# python --version
Python 2.7.17

 

移除当前默认链接:

root@wayde-desktop:/home/wayde/Documents/civ# sudo rm /usr/bin/python

 

新增你需要指定的版本链接:

root@wayde-desktop:/home/wayde/Documents/civ# sudo ln -s /usr/bin/python3.6 /usr/bin/python

 

重新查看当前默认版本,已经修改成功:

root@wayde-desktop:/home/wayde/Documents/civ# python --version
Python 3.6.9

 

posted @ 2020-07-20 16:32  MyCPlusPlus  阅读(299)  评论(0编辑  收藏  举报