Ubunt16.04默认安装python2.7和3.5
注意:系统自带的python千万不能卸载
1:输入python
![66dac22b8d3396570f464bcf6bb5af67.png](https://img-blog.csdnimg.cn/img_convert/66dac22b8d3396570f464bcf6bb5af67.png)
2:输入python3
![d2c3b1b2fa49433b307edae1085d00c0.png](https://img-blog.csdnimg.cn/img_convert/d2c3b1b2fa49433b307edae1085d00c0.png)
3:输入命令sudo add-apt-repository ppa:jonathonf/python-3.6
第一种情况:如果显示不能添加"‘ppa:~jonathonf/ubuntu/python-3.6‘"这个ppa,
![8902e0d3a0c19811ecef6542f2a0fb21.png](https://img-blog.csdnimg.cn/img_convert/8902e0d3a0c19811ecef6542f2a0fb21.png)
使用一下命令
sudo add-apt-repository ppa:deadsnakes/ppa
![cfa89dfc5a10878343c5657cad00df4f.png](https://img-blog.csdnimg.cn/img_convert/cfa89dfc5a10878343c5657cad00df4f.png)
回车
![c90dc0ff8bcc75935ef5bee2e61c1a89.png](https://img-blog.csdnimg.cn/img_convert/c90dc0ff8bcc75935ef5bee2e61c1a89.png)
第二种情况,直接回车即可
![0a5393e86d9f13b490c040b1fd35ca1e.png](https://img-blog.csdnimg.cn/img_convert/0a5393e86d9f13b490c040b1fd35ca1e.png)
4:更新apt源:sudo apt-get update
5:安装python3.6:sudo apt-get install python3.6
![13e011be0d9a1f094873e6a778dfdeab.png](https://img-blog.csdnimg.cn/img_convert/13e011be0d9a1f094873e6a778dfdeab.png)
6:调整python3的优先级,使得python3.6的最高
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
更改默认值,python默认为Python2,现在修改为Python3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
7:此时输入python
![e6116a2566ccc4917a23bf34d6d42015.png](https://img-blog.csdnimg.cn/img_convert/e6116a2566ccc4917a23bf34d6d42015.png)
说说linux软件版本管理命令update-alternatives
原文:https://www.cnblogs.com/1164xiepei-qi/p/14333804.html