| by Arround The Web | No comments

How to Check Python Version in Windows

Python is a famous, all-purpose programming language widely used over the world to create and design websites/ software for automation. The Python applications that are coded in different python versions may not work properly in another python version. Therefore, it is essential to find out the version that is currently running on the system and the version of the application.

In this article, we will go over the possible ways to check out the Python versions on Windows:

  • Using Command Prompt
  • Using PowerShell

Method 1: Check Python Version on Windows Using Command Prompt

Command Prompt is a basic command line utility of Windows to automate various tasks. You can utilize the following method to check the python version on windows using CMD:

  • Through sys Python Module
  • Through “python –version” command

How to Check Python Version Using “sys” Module
Here, the following steps will guide you to utilize the “sys” module to check the python version using CMD. Let’s dig into them:

Step 1: Open Command Prompt
Firstly, press the “Window+R” key to open the Run box. Then type “cmd” in the “Open” drop-down option and hit the “OK” button:

Step 2: Check Python Version
To check the Python version on the Windows Command Line, utilize the below-provided command. The sys module accesses all Python information, which is then filtered using “sys.version_info” to identify the Python version only:

> python -c "import sys; print('{0[0]}.{0[1]}.{0[2]}'.format(sys.version_info))"

Alternatively, follow the provided command to determine Python version without providing format:

> python -c “import sys; print(sys.version)

How to Check Python Version Using “python –version” Command?
To find out the Python version simply utilize the “python –version” command on Windows Command Prompt:

> python --version

Otherwise, type “python” only on Command Prompt. It will display the Python version that is currently installed on the system along with additional information:

> python

You can see that we are currently using the Python “3.10.6” version on Windows.

Method 2: Check Python Version on Windows Using PowerShell

In order to check the Python version using Windows PowerShell, follow up on the below-mentioned instructions.

Step 1: Open Windows PowerShell
Firstly, utilize the “Window+X” combined key to open the power user menu. After then, select the “Windows PowerShell (Admin)” option to open PowerShell as an administrator user:

Step 2: Check Python Version
Simply run the “python –version” command to determine the Python version:

> python --version

You can see that we are using Python version “3.10.6” on Windows:

Alternatively, you can utilize “-V” instead of “–version” on PowerShell:

> python -V

We have effectively explained how to check the Python version on Windows.

Conclusion

Windows PowerShell and Command Prompt are two effective utilities to check the Python version on windows. In the Windows PowerShell and Command Prompt, simply utilize the “python –version” command. However, you can use the “sys” module to check the version as well. In this article, we have illustrated various techniques used to check the Python version on Windows.

Share Button

Source: linuxhint.com

Leave a Reply