How to Check Your Python Version?

Posted in /  

How to Check Your Python Version?
vinaykhatri

Vinay Khatri
Last updated on December 25, 2024

    In this Python tutorial, you will learn how to check the Python version on Windows, macOS, Linux, Ubuntu, Anaconda, and Spyder. Python is one of the most popular programming languages as of 2022, and like other high-level programming languages, Python also has many versions. From 1 st January 2020, Python officially retired the Python version 2 series and now only supports and maintains Python 3.x versions. The latest version of Python is Python 3.9.0, which was released on 5 th October 2020.

    How to Check the Python Version using Python Script/Code

    You can write some code and execute it in order to check the version you are currently using. Python has a built-in module sys that stands for system and using this property you can print the version of the high-level programming language you're using. Example:

    import sys
    print("My Python version is:" , sys.version)

    Output

    My Python version is: '3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]'

    On Jupyter Notebook

    If you are using Jupyter notebook and want to print the in-use version of the high-level programming language on which you are currently working, follow these steps:

    • Open your Jupyter Notebook.
    • Copy and paste the code below and execute by pressing shift + enter .

    Example 1:

    from platform import python_version
    python_version()

    Output

    '3.8.0'

    Alternatively, you can just use the Python sys module and version attribute.

    Example 2:

    import sys
    sys.version

    Output

    '3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]'

    On Windows 10

    In Windows 10, you can check your Python version using the Command Prompt. Follow the following steps to check the Python version on Window 10:

    • Step 1: Open the command prompt by pressing win +r shortcut key and type cmd to open the command prompt.
    • Step 2: Execute Command python –version and hit enter. The Python version will display in the next line.

    On Windows 7

    If you are using Window 7 then follow the steps given below to check the version on your system:

    • Step 1: Open the command prompt by pressing WIN +R shortcut key and type cmd to open the command prompt.
    • Step 2: Execute Command python –version and hit enter. The Python version will be displayed on the next line.

    <Note> Instead of Python version if you are getting this message 'Python' is not recognized as an internal or external command, operable program or batch file. This signifies that the high-level programming language is not installed on your system. P.S. - Know how to install Python on Windows 10 .

    On macOS

    If you are using macOS, you can check the installed Python version on your terminal using the python --version command. Follow the steps below and you will be able to check the installed version of the popular high-level programming language on your macOS:

    • Step 1: Open Spotlight using CMD + Space and type terminal. Press enter to open the terminal.
    • Step 2: In Terminal type command python --version or python -V and Press Enter. The Python version will be displayed in the next line.

    On Linux

    If you are a Linux user, you can check the installed Python version on your Linux bash or Terminal using the python --version or python -v command. Follow the steps given below if you are using Python on Linux:

    • Step 1: Open the terminal or bash application.
    • Step 2: Type command python --version or python -V and hit enter. The version information will display on the next line.

    Example: Type the following command on the terminal:

    $ python --version
    Python 3.8.0 

    On Ubuntu

    If you are an Ubuntu user and want to check the installed Python version on your system then type python --version on your terminal to find the version. Follow the following steps to check the Python version on the Ubuntu operating system:

    • Step1: Open Dash by clicking the upper left symbol.
    • Step 2: Type terminal and open the terminal app.
    • Step 3: Type command python --version and hit enter. The installed Python version will display on the next line.

    On Anaconda

    If you have installed Python using the Anaconda distributed system, then you can check your Anaconda version using the conda --version terminal command and Python version using python --version terminal command.

    Using Spyder, PyCharm, Visual Code Studio, etc.

    PyCharm, Spyder, and Visual code Studio are the Python IDEs and you can write a Python script in these IDEs and check your version information. Execute the code mentioned above and you will find the Python version in no time.

    Conclusion

    Here in this article, you learned how you can check the Python version on various operating systems and platforms. Sometimes you also want to write a code where the program checks the user Python version and execute the files accordingly. So for that, you can use the python sys module to check the same. People are also reading:

    Leave a Comment on this Post

    0 Comments