How to Check Python Version? (Linux, Windows and Mac)

You can check the Python version on different operating systems using the following methods:

Linux and Mac:

  1. Open a terminal:

    • On Linux: Press Ctrl + Alt + T or use the application menu to open the terminal.

    • On Mac: Press Cmd + Space, type "Terminal," and press Enter.

  2. Type the following command:

     bashCopy codepython --version
    

    or

     bashCopy codepython -V
    

    or

     bashCopy codepython3 --version
    

    or

     bashCopy codepython3 -V
    

    This will display the Python version installed on your system.

Windows:

  1. Open Command Prompt:

    • Press Win + R, type "cmd," and press Enter.
  2. Type the following command:

     bashCopy codepython --version
    

    or

     bashCopy codepython -V
    

    or

     bashCopy codepython3 --version
    

    or

     bashCopy codepython3 -V
    

    This will display the Python version installed on your system.

Alternative for all systems:

  1. Open a terminal or command prompt:

  2. Type the following command:

     bashCopy codepython -c "import sys; print(sys.version)"
    

    or

     bashCopy codepython -c "import platform; print(platform.python_version())"
    

    or

     bashCopy codepython3 -c "import sys; print(sys.version)"
    

    or

     bashCopy codepython3 -c "import platform; print(platform.python_version())"
    

    This will provide more detailed information about the Python version, including additional details such as the build and date.

    Learn more with the free online python tutorial and test your knowledge with the online python compiler!