要检查Ubuntu是否已安装Python,您可以打开终端(快捷键:Ctrl + Alt + T),然后输入以下命令:
python --version 或者
python3 --version 如果Python已安装,您将看到类似以下的输出,显示Python的版本号:
Python 3.8.10 如果没有安装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 2已经不再预装,但是Python 3是预装的。如果您需要安装Python 3,可以使用以下命令:
sudo apt update sudo apt install python3 安装完成后,再次运行python3 --version检查是否已成功安装。