轉自: http://www.javashuo.com/article/p-pxwgrdvj-ex.htmlhtml
Ubuntu16.04默認安裝了Python2.7和3.5python
請注意,系統自帶的python千萬不能卸載!spa
輸入命令python命令行
按Ctrl+D退出python命令行3d
輸入命令sudo add-apt-repository ppa:jonathonf/python-3.6htm
按Enter確認blog
輸入命令sudo apt-get update開發
輸入命令sudo apt-get install python3.6get
按Y確認it
調整Python3的優先級,使得3.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
此時再輸入命令python
能夠看到此時已是Python3.6了
添加by xiaou:
若是須要py3.6的開發環境:(由於須要python3.6m的so和/usr/include/python3.6m裏的頭文件):
sudo apt-get install python3.6-dev