Skip to content
Home » Blogs » How to Check Python Version In Windows, Mac, And Linux – Complete Guide

How to Check Python Version In Windows, Mac, And Linux – Complete Guide5 min read

How to Check Python Version

Understanding the version of Python you’re working with is important for many reasons. Knowing whether you are coding with Python or collaborating on a project can save you from compatibility issues. It ensures you’re using the correct libraries and frameworks and following tutorials or documentation compatible with your version. In this blog post, we will learn How to Check Python versions in Windows, Mac, And Linux.

Why Knowing Your Python Version Is Important?

Knowing your Python version is important for several reasons:

1. Compatibility with Libraries and Frameworks

Different versions of Python may have various features, bug fixes, or performance improvements. Libraries and Frameworks may be developed or updated with specific Python versions. Using an incompatible version could lead to errors or unexpected behavior when using these tools. Knowing your Python version ensures compatibility and smooth integration with the libraries and frameworks you want to use.

2. Following Tutorials or Documentation Specific to a Version

Python changes occasionally, with new syntax, functionalities, and best practices introduced in every new version. Tutorials and Documentation often provide instructions altered to specific Python versions, especially when it comes to working with new features or changes in behavior. Knowing your Python version ensures you can follow tutorials and apply the changes correctly. It helps you avoid confusion or frustration from attempting to implement instructions meant for a different version.

ADVERTISEMENT

Checking the Version

Checking the Python Version is different in various operating systems. We will know How to Check Python Versions in Windows, Linux, and Mac.

Here Is How to Check Python Version On Windows

To Check the Python Version Follow the Steps Given Below:

Step 1: Open Command Prompt (CMD): Press ‘Win + R’, type ‘cmd’, and press Enter.

Step 2 Type Command: Once the Command Prompt is open, type either of the following commands:

python --version

or

python -V

Note: The Capital ‘V’ should be there in the second command.

Also Read: How to Learn Python In 30 Days! | Learn & Master Python Programming In a Month

Here Is How to Check Python Version In Linux

In Linux, The Process to Check the Python Version is straightforward and can be done using the terminal. Here are the steps to do it:

Step 1: Open a Terminal: Depending on your Linux distribution, you can find the Terminal application in your system’s application menu or by just searching for “Terminal” in the system’s search bar.

Step 2: Run Python Version Command: Once you have the terminal open, type one of the following given commands and press ‘Enter’:

  • If you are using Python 2 and Python 3 installed and you want to check the version of Python 2, then run the following command:
python --version

And, If you are using Python 3, then run the following command:

python3 --version

Alternatively, you can also use the following command with a ‘-V’ flag:

python -V
python3 -V

Step 3: View the Python Version:

The above command will display the installed Python Version on your system. It will look something like this:

Python 3.8.10

Here Is How to Check Python Version On Mac

To Check your Python version on a Mac, you can use the Terminal application. Follow the steps:

Step 1: Open Terminal: You can find Terminal in the “Utilities” folder within the “Applications” folder. Or You can use Spotlight Search (CMD + Space) to quickly find and open Terminal by typing “Terminal” and pressing Enter.

Step 2: Run Python Version Command: Once the Terminal is open, type either of the following commands:

python --version

or

python -V

Once, you will press Enter it will show the installed Python version.

Step 3: If you are using multiple Python versions of Python installed and you want to specifically check the Python 3 version, then you can use the following command:

python3 --version

or

python3 -V

And again press Enter, to see the Python 3 version installed on your Mac.

Here Is How to Check Python Version Using an IDE

If you’re working with an Integrated Development Environment (IDE) like PyCharm or IDLE, checking the Python version is often even more straightforward. Usually, the version information is displayed at the bottom right side in the IDE window.

How to Check For Multiple Python Versions

To Check Multiple Python Versions You can use the following ways:

  1. Command Line: You can use the command line to check for installed Python versions, On Windows, open Command Prompt and type ‘python – – version’ or ‘python -V’. On macOS or Linux, open Terminal and use ‘python3 – – version’ or ‘python3 – V’. This will display the default Python version installed on your system. To check for other installed versions, you may need to navigate to the directories where Python is installed or check your system’s environment variables.
  2. IDEs: Integrated Development Environments (IDEs) like PyCharm often provide features to manage and switch between Python versions within the IDE settings.

How to Manage Multiple Python Versions

To Manage Multiple Python Versions in a system you can use a Version Manager like ‘pyenv’ (for macOS/Linux) or ‘virtualenv’ **(**cross-platform) are popular tools for managing Python installations. Here’s a brief overview of each:

  • pyenv: Pyenv allows you to install, manage, and switch between multiple versions of Python seamlessly. It provides a simple command-line interface to install specific Python versions and set the global or local version for your projects.
  • virtualenv: Virtualenv creates isolated Python environments, each with its own Python interpreter and set of installed packages. It allows you to work on different projects with different dependencies without affecting system-wide Python installations. While virtualenv doesn’t manage Python versions directly, it can be used in combination with pyenv or with multiple system-installed Python versions.

Project: Checking Python Version Using a Script

There is an interesting way to check the Python Version using a Script. Here is a short script to check the Python Version:

import sys

print("Python version:", sys.version)

When you run the following script, it will display the Python version installed on your system with additional version information. This method is particularly useful if you want to use code to retrieve the Python version or if you are not able to access the command line for version checking.

Conclusion

Finally, checking your Python version is important for ensuring a smooth development process and compatibility with libraries and frameworks, as well as following tutorials and documentation specific to your version. Knowing your Python versions helps you avoid compatibility issues and seamlessly work on projects knowing that you’re using the correct tools and resources.

Tanmay Sinha

PROMOTED

The Ultimate Managed Hosting Platform

2 thoughts on “How to Check Python Version In Windows, Mac, And Linux – Complete Guide5 min read

  1. Pingback: How to Run a Python Script: A Comprehensive Tutorial (2 Ways) - Mr Programmer

  2. Pingback: 9 Common Mistakes Beginners Make in Python - Mr Programmer

Leave a Reply