In this Python tutorial, we will be teaching you how to check the version of your Python installation on the two most popular Operating Systems, windows and Linux.
There are multiple reasons why someone would want to know how to check their Python version. For example, a library you are using requires a newer Python version and you want to check if yours needs to be upgraded. Or maybe you want to check to see if you already have an existing installation of Python (since multiple installations can cause issues).
Check Python Version on Windows
Run the following command in an IDE terminal (or Windows Command prompt) to check your current Python version.
C:\windows\system32> python3 -V
Python 3.10.6
Alternatively, you can also do:
C:\windows\system32> python3 --version
Python 3.10.6
As you can see, my Python version is 3.10.6. As of 2022, this is a fairly recent version of Python and can be considered up-to date. If your Python version is significantly older than the current version, then you should consider upgrading your Python installation.
If you have an older Python installation (Python 2), you will need to run “python” instead of “python3”. Be warned however. If you have a Python3 installation only, and you use “python -V” or “python –version”, it will print out the version of your Python3 installation.
This behavior is unique to Windows. On Linux, “python” will raise an error if there is no Python2 installation, even if there is a Python3 installation.
Check Python Version on Linux
Believe it or not, the process for checking Python version is actually the same on Linux as it is on Windows! This is because Python itself is platform independent, and the commands we are running on the Command Prompt / Terminal are actually being made to Python, not the OS.
Here are the same commands running on Linux, and their output. (I have a different Python version on Linux than Windows, hence the difference).
alterego@alterego-VirtualBox:~$ python3 -V
Python 3.8.10
And here is the other command that we can run.
alterego@alterego-VirtualBox:~$ python3 –V
Python 3.8.10
This marks the end of the Check version of Python Installation on Windows and Linux Tutorial. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the tutorial content can be asked in the comments section below.