How to find your Python version the geek way

As a computer geek, I like to experiment with different command line utilities with the main purpose of finding new ways to automate daily tasks in my own operating system. Python is one of my favorite computer tool so far, as not only it helps me to write my custom utilities, but is also easy to read and understand.

Through this article, you are going to learn how you can find the version of Python which is installed in your own machine. There are many ways to accomplish such task, but for the purpose of this tutorial I am going to share the two I know.

Open a new console in your operating system and run the following command.

What's the one thing every developer wants? More screens! Enhance your coding experience with an external monitor to increase screen real estate.

python –version

Based on my personal experience with the above command, it works both on Windows and Unix based machines. After the above command got executed in my own Mac OS X machine, I got the following output.

Python 2.7.12

This is the first way. Now launch a new Python interactive console to learn the second way. The version of Python you’re running should come automatically as an output in the interactive shell.

If the version of Python is not being displayed after you have launched your Python interactive shell, make use of the following commands.

import sys
sys.version

After I executed the above Python command in my own interactive shell, the following output got printed on the console.

2.7.12 (default, Jun 29 2016, 14:05:02)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]

Final thoughts

As I have mentioned in previous articles and tutorials, there are many ways through which one can accomplish something in their own operating system. If it happens that you know a different way to find the Python version installed in a machine, please share it with us in the comments section.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Leave a Reply

Your email address will not be published. Required fields are marked *