Check Python Version On The Command-Line

Not sure what Python version you’re running? In this short how-to, you’ll learn how to check your Python version. You don’t want to be running an old version unintentionally, even though you just installed the latest! Yes, this happens. It’s easy to check the Python version, so let’s do that.

Check Python version

This simple command works on all operating systems, including Windows, Linux, and MacOS. Assuming you have Python installed, and the terminal open, you can check your current Python version with the following command:

$ python --version
Python 2.7.16

Hopefully, yours says something like 3.7.x or higher. But if it says 2.7.x (or lower), don’t worry just yet.

There have long been two versions of Python: version 2 and 3. They existed alongside, as explained in our article on Python’s history.

On many systems, both versions of Python are installed. This happens when some pieces of software require version 2, while to OS or the user also needs three. In such cases, usually, Python 2 runs when you enter python and Python 3 when you enter python3.

Let’s check the Python version again, but now try with python3:

$ python3 --version
Python 3.7.6

If your output looks similar, congratulations. You have Python 3 installed! If not, please follow the steps on installing Python 3 for your operating system.

Python Courses

Are you enjoying this free tutorial? Please also have a look at my premium courses. They offer a superior user experience with small, easy-to-digest lessons and topics, progress tracking, quizzes to test your knowledge, and practice sessions. Each course will earn you a downloadable course certificate.

The Python Fundamentals Course For Beginners
Now for $29 (from $49)

Python Fundamentals I is a course for beginners that will get you started with Python in no time. Learn all the essentials, test your progress with quizzes and assignments, and bring it all together with the final course project!

Python Course for Beginners

Modules, Packages, And Virtual Environments
Now for $29 (from $49)

Python Fundamentals II covers creating your own modules and packages, using virtual environments and Python package managers to make your life as a programmer easier. Advance your productivity as a Python programmer!

Python Fundamentals 2

Leave a Comment