截至我寫下這篇文章時(官網(wǎng)發(fā)布于 2018-04-18 的 Raspbian)吼鱼,樹莓派系統(tǒng)內(nèi)置的 python 版本仍然停留在 2.7.13
如下步驟可將執(zhí)行 python
命令時運行的環(huán)境升級到 python3
-
安裝 python3
sudo apt install python3
-
卸載 python2.7 (可選)
sudo apt remove python
再執(zhí)行如下命令自動清理 python2.7 的依賴
sudo apt autoremove
-
刪除掉原先 python 的鏈接
sudo rm /usr/bin/python
-
創(chuàng)建一個新的鏈接指向剛剛安裝的 python3.5
sudo ln -s /usr/bin/python3.5 /usr/bin/python
-
測試
輸入
python
顯示結果為
Python 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
可見運行
python
命令時伟骨,默認使用的版本已經(jīng)變?yōu)?python3.5
本文創(chuàng)作時 python 最新版本為 3.5咧最,注意靈活變通命令中使用版本號