In this article, we will get to know the current version of the Python interpreter in the system. Getting the version of the interpreter is really important as the Python interpreter is widely used throughout the industries for computer programming and source coding. It takes an interactive command and executes it.
The interpreter is the one who takes the code and helps in execution. Sometimes the old version of the interpreter-making command doesn’t work properly and as we know the language Python comes with frequent update vision with some added new features, so the user must update the interpreter with the latest release version.
Check Python Version for Mac, Windows, and Linux
Check Python version on Command Line
This method is one of the simplest methods among all other methods as in this method users get the current Python version with one of the inbuilt commands present in Python. Here are some steps that the user must follow to get the currently running version of the Python interpreter:
- Open cmd/terminal/windows PowerShell.
- Now, write the same command as mentioned below in the code box given, and press enter, with this it will return the current Python interpreter version in the form of a string.
For Shell
python -V
For Terminal
python --version
Output:
Python 3.11.4
Check Python Version in Script
For this method, the user needs to import the sys library from sys. version command which will return the user’s current Python version in use. For this method, the user must open the Python shell and write the following command as given below, with this command the user will get the current working version of the Python interpreter in the form of a string. Here is some step that the user must follow to get the currently running version of the Python interpreter:
- Open cmd/terminal/windows PowerShell.
- Write ‘python’ and press enter key to move into the Python interpreter.
- Write the same command given in the input box below, and in the result, the user will get the current interpreter version.
Python3
import sys print ( "User Current Version:-" , sys.version) |
Output:
User Current Version:- 3.11.4
Check Python Version using Platform Module
This function is accessible by importing the platform library and will always return a string of the running user’s Python version. For better understanding, one can go with the following steps:-
- Open cmd/terminal/windows PowerShell.
- Write ‘python’ and press enter key to move into the Python interpreter.
- Now, write the same command as mentioned below in the code box given, and press enter, with this it will return the current Python interpreter version in the form of a string.
Python3
from platform import python_version print ( "Current Python Version-" , python_version()) |
Output:
Current Python Version- 3.11.4
To install the latest version of Python on your system. You can use this useful link which has the description to install the latest version of Python on different systems like Windows, Linux, and MacOS.