Python Version: How to check Python version in Python Terminal?
If you are running your Python terminal and want to check the version of Python you are using then this tutorial is for you. I will show you how to check the version of Python from the Python terminal or from your Python code.
From the shell you can easily check the Python version. But to check the python version from the program or from the Python terminal you have to use the sys module of Python.
You can import the sys module and then get the version from the sys. Here is code screen shot of the program:
Here is the complete program which prints the Python version in terminal.
>>> import sys >>> print(sys.version)
You can use the above code in your python code to get the version of Python in the program. If there is any requirement to know the Python version in the program then you can use the program given here.
In the python program you can also get the Python version. Here are the steps to do so.
Step 1: Create a Python file
You have to create a sample python file, say test.py using any of the Python editors.
Step 2: Add the code
In your test.py file you add following code:
import sys print(sys.version)
Step 3: Run the code
Now run the code by typing python test.py in the terminal.
You program should display the python version as shown below:
We have a large collection of the latest Python programming tutorials. If you beginner is Python searching for the tutorials to learn Python then check these: