要檢查Ubuntu上是否安裝了Python,您可以打開終端(快捷鍵:Ctrl + Alt + T),然后輸入以下命令:
python --version
或者
python3 --version
如果Python已安裝,您將看到類似以下的輸出,顯示Python的版本號:
Python 3.8.5
如果沒有安裝Python,您將看到一個錯誤消息,類似于:
python: can't open file '/usr/bin/python': [Errno 2] No such file or directory
或者
python3: can't open file '/usr/bin/python3': [Errno 2] No such file or directory
在這種情況下,您需要安裝Python。對于大多數Ubuntu版本,Python 3是默認安裝的。如果您需要安裝Python 2,可以使用以下命令:
sudo apt-get update
sudo apt-get install python2
請注意,Python 2已經在2020年1月1日停止支持,因此建議您使用Python 3。