What is Python: Installation Guide | How to Install Python3 & Python2 on Windows, Linux, macOS?

Python is the most famous programming language used in various fields. It has two major versions ie., Python 2 and Python 3. To use the Python language on your devices, it is mandatory to install the required version by following all instructions. Python beginners will face some hurdles in installing python in their Operating systems. So, we have come up with the Python Installation tutorial for beginners and experts to use python on their OS. Here, you will learn how to check the current python version, how to install python on Windows, Linux, macOS, and many other.

In this tutorial of what is python installation guide, you’ll learn the basic instructions that you should aware of:

Introduction to Python Installation Guide

Python is a very versatile language. It has thousands of libraries and modules to work with. As a beginner, you have to think that it is very important to start out with a language. It covers a wide range of functions to deal with basic to complex programs.

No matter what operating system you had, we have covered all python installation steps for Windows, macOS, Linux, etc. Installing or updating or setting up python on your device is the initial step to becoming a python programmer. You can discover various methods to install python on different OS. So, checking the python version before downloading or performing the code in python is a must.


If you’re a beginner to Python ensure to read all the tutorials covered by BtechGeeks and get some idea about the language. It is compatible & flexible with all different operating systems. In fact, the Python programming language is easy to set up. In case, you’re using the Linux system you will have python pre-installed on your OS.

How to check the Python version?

Some operating systems come with Python pre-installed Like macOS or Ubuntu. Other operating systems like Windows don’t have it installed out of the box.

In order to check whether Python is installed or not in open the terminal in macOS or Linux. Write the below command:

python --version


Python 3.7.2

If you’re using windows. Open the CMD and write:

python -v

Another way to check the Python version is to write python. It should open the Python shell or raise an error.
How to check the Python version

If your operating system doesn’t have Python installed.

How to download Python?

One of the best features of Python is its compatibility. It can be easily installed in any operating system. You can install it via command line or GUI.

Python installation in Linux-based operating systems is very easy. In this case, we will check the installation for Ubuntu. It’s almost the same in other Linux distributions.

  1. Install dependencies.
    $ sudo apt-get install software-properties-common
    $ sudo add-apt-repository ppa:deadsnakes/ppa
  2. Update the OS package manager
    sudo apt-get update
  3. Install the latest version
    $ sudo apt-get install python3.8

Note that the version of python will depend on your distribution. For example, installing a Python3.6 the package on Fedora 25 to get Python 3.6.

How to Install Python on windows?

  1. Visit the official website.
  2. Navigate to downloads > windows.
  3. Select your version.
  4. Open the .exe file.
  5. Click install now.
  6. Proceed with next.
  7. Finish the installation and click close.

How to download Python How to download Python 1

How to install Python on macOS?

  1. Do the above steps
  2. From the downloads section select MacOS X
  3. Click on the macOS installer.
  4. Open the downloaded file.
  5. Click to continue with recommended settings.
  6. After finish, you will have it installed.

How to install Python in macOS

Python Installation Tutorial for Linux

One of the best open-source OS is Linux. Also, you can see various Linux-based operating systems. The most commonly used are Ubuntu, Fedora, Linux Mint, Debian. Here, we are going to learn how to perform python installation for both versions 3.x and 2.x. Fedora Linux OS used for Installation of python. Almost all the latest Linux OS have already downloaded Python. You can verify it is installed or not by giving the below commands in the terminal.

For Python 2

$ python2 --version

For Python 3

$ python3 --version

If you saw the python versions as output then you are not allowed to install the python. If no, then you have to install python by following the steps provided here to install successfully:

First, you have to open the terminal or Command prompt from your linux based OS and type the following commands:

$ sudo apt-get update

$ sudo apt-get install python3.6


$ sudo apt-get update

$ sudo apt-get install python2.7

If you are using Ubuntu 16.0 or a newer version, then you can easily install Python 3.6 or Python 2.7 by typing the above commands.

What is the difference between Python2.x and 3.x?

If you’re trying to start learning  Python, you’ll find two versions. The 2.x and the 3.x. What is the difference?

Python is like any other language that has versions. The goal of versioning is to track the updates. Each version has its own features. Why are we versioning the updates of any language?

The goal is to be able to track the updates. In the software industry, updating the language can have a side effect. The update can have a deprecated feature or syntax change. An auto-update can lead to project failure. Versioning helps us to specify a version that our project will run with it. This leads to less error and increases the lifetime of the project.

The version number consists of two parts. Like this (2.7 or 3.8). The first number is referring to a Major change. Change that could lead to deprecate some feature or syntax change. The second number is referring to a minor update or fix. Each update has a changelog. With that changelog, developers can track the changes to update their projects. It’s always recommended to work with the latest version of the language.

In Python, there are two versions 2.x and 3.x. The difference is major. Updating the 2.x project to 3.x will lead to a syntax error. What is the difference between 2.x and 3.x? Which one you should learn?

Integer division:

Divide two integers in 2.x  will not have a float value.

# Python 2.x
print 5 / 2

# 2

# Python 3.x
print(5 / 2)

# 2.5

Print function:

The print function in 3.x brackets is mandatory. The print function in Python2.x brackets are optional.

# Python 2.x
print "Hi weclome to python 2.x"

# Hi weclome to python 2.x

# Python 3.x
print("Hi weclome to python 3.x")

# Hi weclome to python 3.x


In 2.x the implicit string type is ASCII. But with 3.x  it’s UNICODE.

print('sample word')
print(b'sample word')

# Python 2.x 
# <type 'str'>
# <type 'str'>

# Python 3.x
# <class 'str'>
# <class 'bytes'>

In 2.x both are the same type. But In 3.x they are different types. This doesn’t mean that Python2.x doesn’t support Unicode. It supports Unicode with different syntax print('this is a text ') .

Range and xrange:

The statement xrange is deprecated in Python3.x. You can check our full article about the range function.

# Python 2.x
for x in xrange(1, 5):

# 1 2 3 4

# Python 3.x
for x in xrange(1, 5):

Traceback (most recent call last):     
  File "<stdin>", line 1, in <module>  
NameError: name 'xrange' is not defined

It should be
for x in range(1, 5):

# 1 2 3 4

Error handling:

Error exception handling in Python3.x should be defined with as.

# Python 2.x
except NameError, err:
    print err, 'ops defined before assign.'

# output:
(NameError("name 'variable_name' is not defined",), 'ops defined before assign.')

# Python 3.x
except NameError, err:
    print err, 'ops defined before assign.'

 File "<ipython-input-1-942e89fbf9ab>", line 3
    except NameError, err:
SyntaxError: invalid syntax

It should be:
except NameError as err:
    print(err, 'ops defined before assign.')

Note: Python2.7 support ended. If you’re new to python It’s recommended to start with Python3.x.

How to set up a ready python environment?

The different versions of python make it not practical to have a single setup for all projects. If you have a python2.x project, it’ll not work on your python3.x environment. You need to isolate each project with its packages. This concept is called a virtual environment. It’s an isolated environment with a specific version to run your project. Using a virtual environment will help you work with different projects easily. All you need it to activate the environment.

How to set up a virtual environment?
Installing a virtual environment ubuntu

How to set up a virtual environment?

Installing a virtual environment ubuntu

  1. Make sure you have it is installed.
  2. Update your package manager
    sudo apt update
  3. Install the pip package manager.
    $ sudo apt install -y python3-pip
  4. Install the essentials tools.
    $ sudo apt install -y build-essential libssl-dev libffi-dev python3-dev
  5. Installing the virtual environment.
    $ sudo apt install -y python3-venv
  6. Create a virtual env.
    $ python3 -m venv <env_name>
  7. Activate the virtual env.
    $ source <env_name>/bin/activate

Now you have an isolated playground. Any installed package will be in this virtual environment. If you are done you can simply write deactivate to deactivate the environment.

Final Thoughts

You can quickly install python on any operating system by following the instructions prevailing in this tutorial. With its versioning system, you can pick the right version for your project. It’s always advised to work with the newest version. You must know the differences between python versions before deciding to choose the python project. Updating the project depends on what version you’re using. It’s suggested to use a virtual environment for each project. It supports you to run multiple projects on the same machine.