Ubuntu16.04系統自帶兩個版本的python(2.7 and 3.5),假如需要用到python3.6,那麼需要升級python3.5,下面是詳細步驟,親測有效。
終端輸入python3 -V ,查看版本,我的是python3.5
下面挨個執行下面的命令:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
再次輸入python3 -V發現沒有變化還是python3.5,還需要下面步驟
輸入which python3 發現python3 路徑
我的是/usr/bin/python3
cd /usr/bin/
sudo rm python3 刪除原先python3.5
sudo ln -s python3.6 python3 創建軟鏈接
更新 pip
sudo apt-get install python3-pip
再次輸入 python3 -V, 這時候是python3.6
如果 pip 出现 No module named apt_pkg 错误
sudo apt-get remove --purge python3-apt
sudo apt-get install python3-apt