Stay in touch!

Never miss out on the latest articles and get sneak peeks of our favorite classes.

How to Check Python Version for Mac, Windows, and Linux

ProgrammingPythonSkillsHow-to

Preparations: Desktop or laptop with Python installed

 

Total time: 5-10 mins

 

Difficulty: Intermediate

 

Task Yields: After you complete the task, you will be able to check your installed Python versions

 

Web developers, engineers, and other software professionals need to know how to check Python version installed on their machines. Although the process is simple, some beginners may find it hard to figure out how to check Python version.

 

If you’re new to Python, we suggest taking a Python course to become familiar with the syntax and subtleties of the language. 

 

In this article, we’ll guide you through a few easy steps to check Python version on your Mac, Windows, or Linux machine. All you need to begin is a computer with a Python release installed. 

 

Let’s jump right in.

What is Python?  

Python is a programming language used in web development, machine learning, and automation tasks. It is object-oriented, interpreted, and has a clear, simple syntax that makes it easy to learn and use.

 

It is one of the most popular and widely used languages, rivaling Javascript, Java, and C.

 

Python’s core library is extensive and freely distributed. These libraries and packages extend Python’s standard functionality. 

The #1 Reason You Need to Know How to Check Python Version

There are many different versions of Python, and each version operates slightly differently with other dependencies and packages you have installed. Therefore, it’s crucial to ensure you have the correct version of Python installed to support the other dependencies in your project.

 

It is possible to have more than one version of Python installed on your computer. If you are a serious developer, you might simultaneously work on several applications requiring different Python versions.

 

For this reason, developers often run Python inside a virtual environment. In addition, it’s common to run a separate virtual environment for each Python project you work on.

 

A virtual environment is like a virtual machine that runs on your computer and keeps all the Python interpreters, versions, packages, dependencies, and scripts isolated from other Python projects on your computer. 

 

You Might Also Like: How to Run a Python Script (A Complete Guide)

quotation marks

Python is one of the most popular and widely used languages, rivaling Javascript, Java, and C.

How Do I Check if Python is Installed on Linux?

To check if you have Python installed on your Linux machine, open up a terminal and type the command python –version. See below for more information and detailed step-by-step instructions.

How Do I Check if My Python is Windows or Linux?

Typically, the type of machine dictates the Python release. For example, if your computer is a Windows computer, you have a Windows release of Python. You are running a Linux Python release if it is a Linux machine.

 

You can use Python to check what type of machine the current code is running on by running the platform command. Python exports this module as a global, so you can easily check what platform your Python code is running on by typing something like the following:

 

if platform.system() == “Linux”:

     print(“Linux”)

elif platform.system() == “Windows”:

    print(“Windows”)

else:

    print(“Mac”)

 

You Might Also Like: Machine Learning: Why Python?

How Do I Know What Version of Python I Have on My Computer?

Depending on the computer you have, the way you check your Python version will differ slightly. In general, you can open either a terminal or command line prompt and type a command similar to python –version.

how to check python version

How to Check Python Version in 3 Easy Steps

  • Open a terminal, command prompt, or Power Shell

  • Type python –version

  • To check the Python3 version, type python3 –version

Open A Terminal, Command Prompt, or Power Shell

Depending on the machine you are using (Mac, Linux, Windows), you will open up a terminal, command prompt, or Power Shell.

Open Terminal (Mac)

The easiest way to open a Mac laptop or desktop computer terminal is to press command + spacebar. This will open up the search bar. Type “terminal” into the search bar and hit Enter. This will open up a terminal window.

Open Terminal (Linux)

The fastest way to open the terminal on Linux is to use the keyboard shortcut Ctrl + Alt + T. This will open a new terminal window.

Open Command Prompt or Power Shell (Windows)

To open the command line prompt on Windows, click on the Start Menu in the bottom left corner of the screen. Into the search bar that appears there, type “Command Prompt” and hit Enter. This will open a new Command Prompt Window.

 

Follow the same steps to open Power Shell.

Run the Python Version Command

The command to check the version of Python you are running is the same for all three machines: python –version. You can enter this into the Mac, Linux terminal, Windows Command Prompt, or Power Shell.

 

Type the command and hit Enter. A printout will appear on the next line telling you which version of Python you have installed.

Run Python3 to Check Python3 Version

The two most commonly found installations of Python are Python 2.7 and Python 3. These are not versions of Python, they are releases. Therefore, there are different versions of Python 2.7 and different versions of Python3.

 

If you type python –version into the terminal or command line and get back an error that says something like “Command not found: python” then you either don’t have Python installed or have Python3 installed. Type python3 –version instead to check the Python3 version.

 

You Might Also Like: Why Was Python Created? History of Python

Tips for Successful Python Development

To succeed with Python development, you should know how to check Python version and always run your Python projects inside separate virtual environments. 

This will keep all Python versions separate and will stop Python versions from polluting the global scope of your machine.

To set up a virtual environment, follow these steps:

 

  • Install the virtual env module using pip by running pip install virtualenv

  • Navigate to the root directory of your project and run python -m venv name_the_env

Check out this course on Python for more.

Related Content:

Share this article
Back to top