How to Install Python?

How to Install Python?

Python is a popular programming language, and you may need to use it if you are into programming.

But before you use Python, you must install and configure it on your computer.

In this blog, we will discuss how to install Python on Windows, macOS, and Linux.

Install Python on Windows

Installing Python on Windows can be done in 4 steps:

  1. Select the Python version you want to install.
  2. Download the Python installer and run it.
  3. Verify Python installation.
  4. Verify PIP Installation.

Let's explore these installation steps further.

Step 1: Select Python Version to Install

Go to Python's official website and select the version you want to install. Different versions of Python 2 and Python 3 are available on the site.

If you are not sure about what you want to install, just select the latest version.

Step 2: Download the Python Installer and Run It

Then, download the Python installer of the version you have selected.

If you have a 64-bit Operating System, it won't matter which version you install. But for older 32-bit Operating Systems, make sure you install the 32-bit version of Python.

List of Python Installer

Run the installation file once you've completed your download. You will see this installation wizard.

Python Installation Setup

Make sure you select the Add Python 3.10 to PATH button to avoid any hassle in the future.

If you want to do a custom installation, you can proceed with the second option. Else, select the Install Now button.

It will take some minutes to complete the installation. If installed successfully, you will see the "Setup was successful" screen.

Python Setup successful

Step 3: Verify Python Installation

We can verify the Python installation in two ways.

1. From Command Prompt

Search for Command Prompt in the Windows Start button. Then type python and press enter.

If Python has been installed successfully, you will see a version number on the terminal.

Verify Python Installation from command prompt

2. From Python Shell (IDE)

Search Python in the Windows Start menu and select the Python command line.

Python IDE to verify Python installation

Then, to ensure it's working, let's write a simple print statement.

print("Hello world")
Python code to print "Hello World"

This is how it looks like in Python console:

Using Python IDE to run a simple Python program

You can use this Python terminal to run basic Python commands. However, you will need to use IDEs like Atom, Visual Studio Code, PyCharm, etc., to run large projects.

Step 4. Verify PIP Installation

After successfully installing Python, you can run your Python code through the terminal.

But you will need to use Python packages once you start building your projects. Thankfully, Python has a package manager called pip for exactly this purpose  

You don't have to install pip separately as it comes installed by default. To ensure that pip is installed, type the pip -V command in the Command Prompt.

If you get the following screen, it means pip has been installed.

Verify pip installation using command prompt

That's about it. You have successfully installed Python on Windows. Now, we will see how to install Python on Mac.

Install Python on Mac

If you have macOS, Python is already installed on your computer.

However, it has Python 2.7, which is not a compatible version to use today.

So, you have to update Python to the latest version on your Mac. You can do this in two ways:

  • Installing Python with command line
  • Installing Python with an online installer

We will also see how to verify the Python installation on Mac.

Install Python With the Command Line on Mac

Follow these steps to get Python through the command line.

Step 1: Install HomeBrew

HomeBrew is a package manager for macOS. To install Python, you first need to install HomeBrew.

Follow these steps:

  1. Open Terminal
  2. Go to Launchpad -> Other -> Terminal
  3. Install HomeBrew with the following commands
/usr/bin/ruby -e "$(curl -fsSL"
Commands to install HomeBrew on Mac

This will install HomeBrew, and you can now use it to install Python. If you face difficulties installing HomeBrew, refer to its official documentation.

Step 2: Install Python

Now you can install/update Python with the following command:

brew install python3
Install Python in Mac using brew

Install Python With the Online Installer on Mac

We can also install Python using the Python installer provided on the official site of Python.

Here are the steps you need to follow:

  1. Go to Python Official Site and download Python with standard macOS .PKG format.
  2. Then run the downloaded file. Select Continue when you can. You will also have to Agree on the Read Me file.
  3. The installer will ask where to install Mac, so choose the drive you want.
  4. After a few easy setups, Python will be installed on your Mac.

Verify Python Installation on Mac

Let's end the Python installation with a simple verification.

To ensure that Python (the version you just installed, let's say 3.7.4) has been set up, run the following command on your terminal.

python –version

Python 3.7.4
Command to check Python version on Mac

If you get the version you installed, the installation is verified.

Install Python on Linux

Just like Mac, most Linux distributions like Debian already have Python installed.

To check whether your Linux has Python, run the following command on the terminal.

python –version
Command to check Python version on Linux

If it shows the following message:

  • "python" not found - Python is not installed
  • Python "version-number" - Python is installed

We have two ways of installing Python on Linux:

  • Installing Python using the package manager
  • Building from source code

After this, we will see how to verify Python installation and how to update the Python version (if you already have Python in your Linux).

Let's get started.

Install Python on Linux Using Package Manager

You can install Python on almost every Linux system using the following command:

sudo apt-get install python3.10
Command to install Python 3.10 on Linux

Note that this Python command is version-specific. For example, if you want to install Python 2.7, then you need to write:

sudo apt-get install python2.7
Command to install Python 2.7 on Linux

Once you enter this command, it will ask for your sudo password.

The command also allocates the hard disk space Python needs for installation. Don't worry if the terminal flashes a message to ask where you want to continue with the process.

Type Y (i.e., Yes) and press enter, and the installation begins.

Your terminal will fetch and install many packages for you. You will just have to wait for some time until the process ends.

If it ends without any error message, the installation is complete.

Build From Source Code

This method requires multiple commands and dependencies installed on your computer.

So before starting, make sure you install git, gcc, and make if you don't have them already.

You need to follow three steps to Build Python from Source Code.

  1. Get the source code
  2. Configure
  3. Build

1. Get the Source Code

The Python source code from Python's official GitHub repository is:

Now let's clone it using the following command.

git clone
Command to get the Python Source Code from git

2. Configure

Navigate to the directory where we cloned the Python source code with

cd cpython
Command to change the directory

Now to configure, run

./configure –prefix=$HOME/python3.10
Command to configure Python

The configuration begins once you hit enter.

If the process ends without any error, the configuration is done.

3. Build

This is the final step. To build the files, run

 sudo make
Command to build files

Then, run

sudo make install
Command to install the built files

This will put the built files in the location specified by configure's –prefix.

Verify Python Installation on Linux

To verify, simply run the command

Command to install Python on Linux

or the version you installed.

If the output is

Python 3.10.0

Python installation is verified.

Update Python Version on Linux

If you already have Python installed, you can update it to any version you want.

Suppose you want Python 3.10.7. To update, run:

sudo apt-get update

sudo apt-get install python3.10.7

Frequency Asked Questions

1. Do I need to install PIP for Python?

PIP (Pip Install Package) is a Python package manager. When you install Python, pip is installed along with it.

You can check whether pip is installed on your computer using pip command in the terminal.

If pip is not installed, you can install it with this command:

For Windows:

Command to install pip on Windows

For Ubuntu:

apt install python3-pip
Command to install pip on Ubuntu

For Mac:

Command to install pip on Mac

2. How to install Python on Ubuntu?

The easy way of installing Python on Ubuntu is by running the following command on the terminal:

sudo apt-get install python3.10
Command to install Python on Ubuntu

3. Which version of Python should I install?

Unless the company you work for tells you to work in a specific version, you can simply go with the latest version of Python.

4. How to check if Python installation is successful?

To check if Python is successfully installed, run the following command:

For Windows

python –version
Command to check Python version on Python

For Mac

Python -version
Command to check Python version on Mac

For Linux

python –version
Command to check Python version on Linux

If the output of these commands gives you the Python version, it has been successfully installed.

For example, if you installed Python 3.10, the output will be:

Python 3.10.0