温馨提示×

如何检查 Ubuntu 上是否已安装 Python

小樊
45
2025-11-30 18:20:43
栏目: 编程语言

要检查 Ubuntu 上是否已安装 Python,请按照以下步骤操作:

  1. 打开终端(快捷键:Ctrl + Alt + T)。

  2. 输入以下命令并按 Enter 键:

    python --version
    

    或者

    python3 --version
    
  3. 如果系统已安装 Python,您将看到类似于以下的输出,显示 Python 的版本号:

    Python 3.8.10
    

    如果系统未安装 Python,则会收到一个错误消息,例如:

    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    

    或者

    Command 'python3' not found, but can be installed with:
    
    sudo apt install python3
    

根据输出结果,您可以判断是否已安装 Python 以及其版本。如果尚未安装,您可以使用 sudo apt install python3 命令来安装 Python 3。

0